简体   繁体   English

使用Python和NumPy组合数组

[英]Combining an array using Python and NumPy

I have two arrays of the form: 我有两个形式的数组:

a = np.array([1,2,3])
b = np.array([4,5,6])

Is there a NumPy function which I can apply to these arrays to get the followng output? 是否可以将NumPy函数应用于这些数组以获取跟随输出?

[[1,4],[2,5][3,6]]
np.vstack((a,b)).T

returns 回报

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

and

np.vstack((a,b)).T.tolist()

returns exactly what you need: 完全返回您需要的内容:

[[1, 4], [2, 5], [3, 6]]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM