創建numpy
陣列之後,我期待追加後創作:追加NumPy的陣列後創建
numpy_array = np.zeros(2,3)
numpy_array[0][1].append(4,5)
凡輸出numpy_array[0][1]
將[0,4,5]
什麼是做到這一點的最好辦法?
創建numpy
陣列之後,我期待追加後創作:追加NumPy的陣列後創建
numpy_array = np.zeros(2,3)
numpy_array[0][1].append(4,5)
凡輸出numpy_array[0][1]
將[0,4,5]
什麼是做到這一點的最好辦法?
如果創建一個numpyp.zeros(2,3)
你會得到一個TypeError
(與代碼波紋管過帳正確的方式來使用它)。
可以使用複製到numpy的陣列的[0. 0. 0.]
的[4, 5]
列表:
np.zeros([2,3]) #note the arg is a list type
numpy_array[0][1:3] = [4,5]
這[1:3]
得到的位置間隔。
'numpy.int32'對象沒有屬性'追加' – aerokite
有沒有什麼辦法可以創建一組數組,你可以在numpy中添加額外的值? – Jason
你需要整數數組嗎? – aerokite