[英]How can I concatenate a list of 2D numpy arrays?
I have a list of nested numpy arrays of shape (30,3). 我有一个嵌套的numpy数组(30,3)列表。 I tried to use numpy's vstack
, hstack
and concatenate
, but I get an error: ValueError: all the input array dimensions except for the concatenation axis must match exactly
我尝试使用numpy的vstack
, hstack
和concatenate
,但是我收到一个错误: ValueError: all the input array dimensions except for the concatenation axis must match exactly
`[array([[[430, 110, 10],
[ 62, 167, 10],
[116, 136, 10],
[341, 104, 10],
[ 21, 116, 10],
[371, 20, 10],
[343, 197, 10],
[ 59, 308, 10],
[ 33, 23, 10],
[215, 70, 10],
[256, 73, 10],
[ 94, 397, 10],
[135, 251, 10],
[202, 283, 10],
[233, 313, 10],
[319, 13, 10],
[ 98, 273, 10],
[261, 167, 10],
[160, 296, 9],
[137, 56, 10],
[ 21, 320, 10],
[ 77, 109, 9],
[295, 356, 10],
[178, 425, 10],
[259, 35, 9],
[319, 416, 9],
[386, 331, 9],
[319, 43, 9],
[209, 409, 9],
[115, 199, 9]]], dtype=uint16),` etc
I would like it to transform this into a normal list of lists, so getting rid of the array
signs, just a plain list that I can easily manipulate. 我希望它将它转换为正常的列表列表,因此摆脱了array
符号,只是一个我可以轻松操作的简单列表。
If you want a plain list without the array
signs, use <your_array>.tolist()
The .tolist()
will convert it to a plain list which is easily manipulatable. 如果你想要一个没有array
符号的普通列表,请使用<your_array>.tolist()
. .tolist()
将它转换为一个易于操作的普通列表。 I hope this helps you 我希望这可以帮助你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.