I want to reshape the numpy array as it is depicted, from 3D to 2D. Unfortunately, the order is not correct.
A assume to have a numpy array (1024, 64, 100) and want to convert it to (1024*100, 64).
Does anybody has an idea how to maintain the order?
I have a sample data
data[0,0,0]=1
data[0,1,0]=2
data[0,2,0]=3
data[0,3,0]=4
data[1,0,0]=5
data[1,1,0]=6
data[1,2,0]=7
data[1,3,0]=8
data[2,0,0]=9
data[2,1,0]=10
data[2,2,0]=11
data[2,3,0]=12
data[0,0,1]=20
data[0,1,1]=21
data[0,2,1]=22
data[0,3,1]=23
data[1,0,1]=24
data[1,1,1]=25
data[1,2,1]=26
data[1,3,1]=27
data[2,0,1]=28
data[2,1,1]=29
data[2,2,1]=30
data[2,3,1]=31
and I would like to have an outcome like this:
array([[ 1., 2., 3., 4.],
[ 5., 6., 7., 8.],
[ 9., 10., 11., 12.],
[ 20., 21., 22., 23.],
[ 24., 25., 26., 27.],
[ 28., 29., 30., 31.]])
Moreover, I would also like to have the reshaping in the other way, i.e. from:
array([[ 1., 2., 3., 4.],
[ 5., 6., 7., 8.],
[ 9., 10., 11., 12.],
[ 20., 21., 22., 23.],
[ 24., 25., 26., 27.],
[ 28., 29., 30., 31.]])
to the desired output:
[[[ 1. 20.]
[ 2. 21.]
[ 3. 22.]
[ 4. 23.]]
[[ 5. 24.]
[ 6. 25.]
[ 7. 26.]
[ 8. 27.]]
[[ 9. 28.]
[ 10. 29.]
[ 11. 30.]
[ 12. 31.]]]