python中的数组形状

时间:2013-06-18 19:38:04

标签: python numpy

这将是一个相当愚蠢的问题,尽管它很烦人。我列出了800个ndarray,每个都有7680个元素。我如何得到这个< 800,7680>格式?

enter image description here

1 个答案:

答案 0 :(得分:4)

将其传递给np.array工厂函数。举个例子:

>>> lst = [np.zeros(7680) for x in range(800)]  #just a list of 800 ndarrays ...
>>> arr = np.array(lst)   #make them into an array
>>> arr.shape   #shape looks OK to me :-)
(800, 7680)