title: Python Reshape 3d array into 2d
body: <p>I want to reshape the numpy array as it is depicted, from 3D to 2D. Unfortunately, the order is not correct.</p>
  
  <p>A assume to have a numpy array (1024, 64, 100) and want to convert it to (1024*100, 64).</p>
  
  <p>Does anybody has an idea how to maintain the order?</p>
  
  <p><a href="https://i.stack.imgur.com/YZ1ra.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YZ1ram.png" alt="Image - click here"></a></p>
  
  <p>I have a sample data</p>
  
  <pre><code>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
  </code></pre>
  
  <p>and I would like to have an outcome like this:</p>
  
  <pre><code>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.]])
  </code></pre>
  
  <hr>
  
  <p>Moreover, I would also like to have the reshaping in the other way, i.e. from:</p>
  
  <pre><code>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.]])
  </code></pre>
  
  <p>to the desired output:</p>
  
  <pre><code> [[[  1.  20.]
    [  2.  21.]
    [  3.  22.]
    [  4.  23.]]
  
   [[  5.  24.]
    [  6.  25.]
    [  7.  26.]
    [  8.  27.]]
  
   [[  9.  28.]
    [ 10.  29.]
    [ 11.  30.]
    [ 12.  31.]]]
  </code></pre>