我希望得到关于如何做到这一点的指导:
使用hstack水平堆叠两个数组,最后将结果数组与第三个数组垂直堆叠。
input_list = [[[1, 2], [5, 6]], [[3, 4], [7, 8]], [[9, 10, 11, 12]]]
请看下图中提到的问题:
发布于 2020-12-27 20:24:57
你可以这样做:
a = np.array(([1,2],[5,6]))
b = np.array(([3,4],[7,8]))
c = np.array([9,10,11,12])
h = np.hstack((a,b))
result = np.vstack((h,c))
a,b,c的数组是输入。首先用hstack()水平堆叠a和b。然后,使用vstack()将生成的数组h与c垂直堆叠。
在您的案例中:
input_list = [[[1, 2], [5, 6]], [[3, 4], [7, 8]], [[9, 10, 11, 12]]]
a = input_list[0]
b = input_list[1]
c = input_list[2]
h = np.hstack((a,b))
result = np.vstack((h,c))
编辑:
此处:https://numpy.org/doc/stable/reference/generated/numpy.hstack.html
发布于 2020-12-29 19:45:48
另一种解决方案:
请看一下这里提到的这张照片。
https://stackoverflow.com/questions/65469914
复制