我有一个像这样的numpy2d数组[[[1,1,1],[5,7,3]],[[1,4,5],[8,3,9]]]
我只想在我的一列中添加一个三元组[0,0,0]
。你知道吗
我用这种方式尝试函数np.append
:
np.append(myArray, [[0,0,0]], axis=0)
但它给了我一个错误:
all the input arrays must have same number of dimensions.
所以我试着:
myArray[0]=np.append(myArray[0], [[0,0,0]], axis=0)
获取所需的列,但出现错误:
could not broadcast input array from shape (3,3) into shape (2,3).
有没有办法把我的三胞胎只加到myArray
的一列?你知道吗
嵌套列表或二维数组的形状必须为矩形。这意味着所有行都有相同的列,所有列都有相同的行。您可以看到: setting null values in a numpy array向数组中添加空值
相关问题 更多 >
编程相关推荐