擅长:python、mysql、java
<p>您可以使用numpy中的<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.stack.html" rel="nofollow noreferrer">stack</a>函数。那么你的代码应该是:</p>
<pre><code>base=np.array([[20,30],[50,60],[70,80],[10,30]])
print(np.shape(base))
nsample=10
tmp = []
for i in range(nsample):
id_pick = np.random.choice(np.shape(base)[0], size=(np.shape(base)[0]))
print(id_pick)
boot1=base[id_pick,:]
tmp.append(boot1)
tmp = np.stack(tmp, axis=-1)
print(tmp)
</code></pre>