Python 如何在numpy中跨多个轴连接多个数组
我有以下Python 如何在numpy中跨多个轴连接多个数组,python,numpy,Python,Numpy,我有以下numpy数组维度:[64897]。这些数据是在每次实验后生成的。我一共有8名受试者,每个受试者做了6次实验 因此,我希望最后有一个4维数组,大小如下:[8,6,64897] 如何在python中的numpy中实现这一点 非常感谢您的帮助 根据@rafaelc,以下是解决方案: total_slices = [] for i in range(8): slices_ = [] for j in range(6): slices = result_of_e
numpy
数组维度:[64897]
。这些数据是在每次实验后生成的。我一共有8名受试者,每个受试者做了6次实验
因此,我希望最后有一个4维数组,大小如下:[8,6,64897]
如何在python中的numpy
中实现这一点
非常感谢您的帮助 根据@rafaelc,以下是解决方案:
total_slices = []
for i in range(8):
slices_ = []
for j in range(6):
slices = result_of_experiment() # This will return an np.array of shape: [64, 8970
slices_.append(slices)
slices = np.stack(slices_, axis=0)
print("slices.shape", slices.shape)
total_slices.append(slices)
total_slices = np.stack(total_slices, axis=0)
print("total_slices.shape", total_slices.shape)
查看
np.stack
指定axis=0