Python Forum
reshape from 3D to 3D matrix - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: reshape from 3D to 3D matrix (/thread-22427.html)



reshape from 3D to 3D matrix - paul18fr - Nov-12-2019

Hi

In the following example, I'm still trying to find a way to reshape the 2D matrix into a 3D one:
  • the columns remain unchaged
  • they are moved in depth column 1 moves to (1, x, x), column 2 moves to (2, x, x) and so on


But is reshape the best tool?

Thanks for any advice

Paul
n = 100
m = 10
# order = 'C' => in line
# order = 'F' => in columns
A = np.arange(n*m).reshape( (n, m), order='F') 
B = np.reshape(A, (10,n,1), order='F')
C = np.reshape(A, (10,n,1), order='C')
D = np.reshape(A, (10,n,1), order='A')