title: Numpy - Reshape and partition 2D array to 3D
body: <p>Is there a way to partition and reshape a 2D array to a 3D one. Like the following example:</p>
  
  <p><a href="https://i.stack.imgur.com/OUjlv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OUjlv.png" alt="enter image description here"></a></p>
  
  <p>Basically, I have a 4x4 matrix on the left and I want a 2x2x4 matrix in the way shown, so that I can apply numpy.mean on the 3rd axis. In reality the matrix I have is really huge, so that's why looping over the blocks is not an option. </p>
  
  <p>Any help is greatly appreciated. </p>