数组的np数组的Python列表 [英] Python List of np arrays to array

查看:105
本文介绍了数组的np数组的Python列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将2d numpy数组的列表转换为2d numpy数组.例如

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]))

我想从此列表中删除的是一个数组(50,10).但是,当我尝试以下操作时,得到了(10,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)

有想法吗?

推荐答案

您要堆叠它们:

np.vstack(dat_list)

这篇关于数组的np数组的Python列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆