我有5000个左右的shape=(1,2000)的数组,我想要实现每循环一次,数组末尾就添加一个数组,最终生成shape=(5000,2000)的大数组,应该如何实现呢?
a = np.random.random((1,2000))
# a.shape (1, 2000)
b = np.concatenate([a for i in range(5000)])
# b.shape (5000, 2000)
list.append(每次循环的数组)
A=[]
B=[i for i in range(2000)]# shape(1,2000)
for i in range(5000):
A.append(B)
#A shape(5000,2000)
>>> import numpy as np
>>> arr = np.vstack([np.random.random(2000) for i in range(5000)])
>>> arr.shape
(5000, 2000)
array=[1,2,3,4];
sumArray=[];
for i in range(5000):
sumArray.append([])
sumArray[i].append(array)
print(sumArray)
看看这个例子有没有用