Numpy重塑一个具有特定顺序的数组

MLe*_*ria 1 python arrays numpy reshape

假设我有这个数组x:

x = array([1, 2, 3, 4, 5, 6, 7, 8])
x.shape = (8,1)
Run Code Online (Sandbox Code Playgroud)

我想重塑它成为

array([[1, 3, 5, 7], 
       [2, 4, 6, 8]])
Run Code Online (Sandbox Code Playgroud)

这是x上的重塑(2,4)但是直接的方式:

y = x.reshape(2,4)
Run Code Online (Sandbox Code Playgroud)

我变成了

array([[1, 2, 3, 4],
       [5, 6, 7, 8]])
Run Code Online (Sandbox Code Playgroud)

那不是我想要的.有没有办法以特定的方式转换数组?

mic*_*234 6

In[4]: x.reshape(4, 2).T
Out[4]: 
array([[1, 3, 5, 7],
       [2, 4, 6, 8]])
Run Code Online (Sandbox Code Playgroud)