What's the simplest way to extend a numpy array in 2 dimensions?

前端 未结 7 1007
后悔当初
后悔当初 2020-12-02 13:00

I have a 2d array that looks like this:

XX
xx

What\'s the most efficient way to add an extra row and column:

xxy
xxy
yyy
         


        
7条回答
  •  星月不相逢
    2020-12-02 13:48

    Answer to the first question:

    Use numpy.append.

    http://docs.scipy.org/doc/numpy/reference/generated/numpy.append.html#numpy.append

    Answer to the second question:

    Use numpy.delete

    http://docs.scipy.org/doc/numpy/reference/generated/numpy.delete.html

提交回复
热议问题