答案 0 :(得分:0)
好的,这是一种解决方案。我相信还有其他方法可以做到。
import numpy as np
#Generate 24 element 1D array and reshape to 6 rows and 4 columns
a_Array = arange(24).reshape(6, 4)
#reshape to distribute data along axis 2 then axis 1 and then axis 0 in order,
#this is what numpy reshape does by default
a_Array.reshape(2,3,4)
#Swap axes 1 and 2
a_Array.reshape(2,3,4).swapaxes(1,2)
#Transpose to arrange data with data distributed along axis 1
a_Array.reshape(2,3,4).swapaxes(1,2).T
链接1通常帮助理解多维数组。 链接2用于生成附有图片的视觉效果。