我有三个I1,I2,I3
数组,其形状为(1,9,2)
。我正试图追加,但有一个错误。新数组应该具有形状(3,9,2)
。
import numpy as np
I1 = np.array([[[0, 2],
[2, 3],
[2, 5],
[3, 4],
[3, 6],
[4, 1],
[4, 7],
[5, 6],
[6, 7]]])
I2 = np.array([[[1, 1],
[2, 3],
[2, 5],
[3, 4],
[3, 6],
[4, 1],
[4, 7],
[5, 6],
[6, 7]]])
I3 = np.array([[[2, 2],
[2, 3],
[2, 5],
[3, 4],
[3, 6],
[4, 1],
[4, 7],
[5, 6],
[6, 7]]])
I=np.append(I1,I2,I3,axis=0)
错误是
in <module>
Iit=np.append(Iit1,Iit2,Iit3,axis=0)
File "<__array_function__ internals>", line 4, in append
TypeError: _append_dispatcher() got multiple values for argument 'axis'
发布于 2022-06-27 09:28:49
使用I=np.concatenate([I1,I2,I3],axis=0)
而不是append
。Append做了您希望从列表中得到的事情(无论如何,为了内存分配的原因,不要在numpy中使用它!)
发布于 2022-06-27 09:39:26
https://stackoverflow.com/questions/72769747
复制相似问题