Python中的串联多维阵列
我有两个数组c1
和c2
带有尺寸(1,2,2)
。我想将数组附加到新数组c3
中。电流和所需的输出附加。
import numpy as np
arC1 = []
arC2 = []
C1=np.array([[[0, 1],[0,2]]])
arC1.append(C1)
C2=np.array([[[1, 1],[2,2]]])
arC2.append(C2)
C3=np.append(C1,C2)
当前输出是
array([0, 1, 0, 2, 1, 1, 2, 2])
所需的输出是
array([[[0, 1],[0,2]],[[1, 1],[2,2]]])
C3[0]=array([[0, 1],
[0, 2]])
C3[1]=array([[1, 1],
[2, 2]])
I have two arrays C1
and C2
with dimensions (1, 2, 2)
. I want to append the arrays into a new array C3
. The current and desired outputs are attached.
import numpy as np
arC1 = []
arC2 = []
C1=np.array([[[0, 1],[0,2]]])
arC1.append(C1)
C2=np.array([[[1, 1],[2,2]]])
arC2.append(C2)
C3=np.append(C1,C2)
The current output is
array([0, 1, 0, 2, 1, 1, 2, 2])
The desired output is
array([[[0, 1],[0,2]],[[1, 1],[2,2]]])
C3[0]=array([[0, 1],
[0, 2]])
C3[1]=array([[1, 1],
[2, 2]])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用轴函数的参数附加。
我认为 np.Append(C1,C2,Axis = 0)是您想要的。
You can use axis parameter of function append.
I think np.append(C1, C2, axis=0) is what you want.