Python List of np arrays to array

匿名 (未验证) 提交于 2019-12-03 01:47:02

问题:

I'm trying to turn a list of 2d numpy arrays into a 2d numpy array. For example,

dat_list = [] for i in range(10):     dat_list.append(np.zeros([5, 10]))

What I would like to get out of this list is an array that is (50, 10). However, when I try the following, I get a (10,5,10) array.

output = np.array(dat_list)

Thoughts?

回答1:

you want to stack them:

np.vstack(dat_list)


转载请标明出处:Python List of np arrays to array
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!