title: Sliding windows from 2D array that slides along axis=0 or rows to give a 3D array
body: <p>I have a 2-d numpy array of this form:</p>
  
  <pre><code>[[  0.   1.   2.   3.   4.]
   [  5.   6.   7.   8.   9.]
   [ 10.  11.  12.  13.  14.]
   [ 15.  16.  17.  18.  19.]
   [ 20.  21.  22.  23.  24.]
   [ 25.  26.  27.  28.  29.]
   [ 30.  31.  32.  33.  34.]
   [ 35.  36.  37.  38.  39.]
   [ 40.  41.  42.  43.  44.]
   [ 45.  46.  47.  48.  49.]]
  </code></pre>
  
  <p>I want to construct a view of the array, grouping its elements in a moving window (of size 4 in my example). My result should be of shape <code>(6, 4, 5)</code> and I can construct it as follows:</p>
  
  <pre><code>res = []
  mem = 4
  for i in range(mem, X.shape[0]+1):
      res.append(X[i-mem:i, : ])
  res = np.asarray(res)
  print res.shape
  </code></pre>
  
  <p>I want to avoid reallocation, so I wonder if I can construct a view to give this result, with as_strided for example.</p>
  
  <p>An explanation of the process is very welcome.</p>
  
  <p>Thanks</p>