Numpy: Concatenating multidimensional and unidimensional arrays

风流意气都作罢 提交于 2019-11-30 06:45:19

unutbu's answer works in general, but in this case there is also np.column_stack

>>> x
array([[1, 2],
       [4, 5]])
>>> y
array([3, 6])

>>> np.column_stack((x,y))
array([[1, 2, 3],
       [4, 5, 6]])

Also works:

In [22]: np.append(x, y[:, np.newaxis], axis=1)
Out[22]: 
array([[1, 2, 3],
       [4, 5, 6]])
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!