简体   繁体   English

numpy合并两个数组我可以像这样制作一个numpy数组吗?

[英]Numpy merge two arrays can i make a numpy array like this?

I am trying two array like this. 我正在尝试这样的两个数组。 It's different from column_stack so I am not able to find how to do it from documentation or google search. 它与column_stack不同,因此我无法从文档或Google搜索中找到方法。

I have arrays a and b . 我有数组ab How can I make c from them ? 我怎样才能让c从他们身上?

a = [[1, 2],[3, 4]]
b = [[5 , 6]]

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

I need this to input the values to theanets. 我需要此值将值输入到theanets。

In [54]:
a = np.array([[1, 2],[3, 4]])
a
Out[54]:
array([[1, 2],
       [3, 4]])

In [55]:
b = np.array([[5 , 6]])
b
Out[55]:
array([[5, 6]])


In [96]:
c = [[a[n].tolist() , b[:,n].tolist()] for n in range(len(a))]
c
Out[96]:
[[[1, 2], [5]], [[3, 4], [6]]]

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

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