How to add a new row to an empty numpy array

前端 未结 6 594
旧时难觅i
旧时难觅i 2020-11-28 01:13

Using standard Python arrays, I can do the following:

arr = []
arr.append([1,2,3])
arr.append([4,5,6])
# arr is now [[1,2,3],[4,5,6]]

Howev

6条回答
  •  甜味超标
    2020-11-28 01:42

    I want to do a for loop, yet with askewchan's method it does not work well, so I have modified it.

    x = np.empty((0,3))
    y = np.array([1,2,3])
    for i in ...
        x = np.vstack((x,y))
    

提交回复
热议问题