I want to reshape a into b, how to quickly do it?
Basically, when reshaping the array, how to always use the first item in each group, then the second item, then the third one?
Input:
import numpy as np
# 3 repeats, each has 2 variables, each has 4 times
a=np.array([[['r1_v1_t1','r1_v1_t2','r1_v1_t3','r1_v1_t4'],
['r1_v2_t1','r1_v2_t2','r1_v2_t3','r1_v2_t4']],
[['r2_v1_t1','r2_v1_t2','r2_v1_t3','r2_v1_t4'],
['r2_v2_t1','r2_v2_t2','r2_v2_t3','r2_v2_t4']],
[['r3_v1_t1','r3_v1_t2','r3_v1_t3','r3_v1_t4'],
['r3_v2_t1','r3_v2_t2','r3_v2_t3','r3_v2_t4']]
])
# 4 times, each has 3 repeats, each has 2 variables
b=np.array([[['r1_v1_t1','r1_v2_t1'],['r2_v1_t1','r2_v2_t1'],['r3_v1_t1','r3_v2_t1']],
[['r1_v1_t2','r1_v2_t2'],['r2_v1_t2','r2_v2_t2'],['r3_v1_t2','r3_v2_t2']],
[['r1_v1_t3','r1_v2_t3'],['r2_v1_t3','r2_v2_t3'],['r3_v1_t3','r3_v2_t3']],
[['r1_v1_t4','r1_v2_t4'],['r2_v1_t4','r2_v2_t4'],['r3_v1_t4','r3_v2_t4']]])
# 4 times, each has 2 variables, each has 3 repeats
#print(a.T)
#print(np.reshape(a,(4,3,2), order='F')) not work
#print(np.reshape(a,(4,3,2))) not work
a.reshape(b.shape, order='F')?b=a.TJust transpose it.