我有一个3D数组点,我希望在平面数组中附加相应的值。
points = [[1,2,3],[4,5,6]]
info = [1,2]
是否有内置方法将第二个数组中的元素追加到第一个数组中的相应位置?
output = [[1,2,3,1],[4,5,6,2]]
答案 0 :(得分:2)
使用np.hstack
:
points = np.array([[1,2,3],[4,5,6]])
info = np.array([1, 2])
output = np.hstack([points, info.reshape(2,1)])
输出:
array([[1, 2, 3, 1],
[4, 5, 6, 2]])