【发布时间】:2021-11-06 09:24:13
【问题描述】:
我有形状的ndarray:
(20640, 7)
我正在尝试添加新列:
np.append(x, [m[:,0], m[:,1]], axis = 1)
地点:
m[:,0].shape = m[:,1].shape = (20640,)
我得到了错误:
ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 20640 and the array at index 1 has size 2
获取此错误的简单示例: 将 numpy 导入为 np
x = np.ones((20640, 7))
m = np.ones((20640, 2))
np.append(x, [m[:,0], m[:,1]], axis = 1)
如何添加这两列?
【问题讨论】:
-
你能提供一个最小的例子吗? (以及预期的输出)
标签: python python-3.x numpy