title: Sliding window of M-by-N shape numpy.ndarray
body: <p>I have a Numpy array of shape (6,2):</p>
  <pre><code>[[ 0, 1],
   [10,11],
   [20,21],
   [30,31],
   [40,41],
   [50,51]]
  </code></pre>
  <p>I need a sliding window with step size <code>1</code> and window size <code>3</code> like this:</p>
  <pre><code>[[ 0, 1,10,11,20,21],
   [10,11,20,21,30,31],
   [20,21,30,31,40,41],
   [30,31,40,41,50,51]]
  </code></pre>
  <p>I'm looking for a Numpy solution. If your solution could parametrise the shape of the original array as well as the window size and step size, that'd be great.</p>
  <hr />
  <p>I found this related answer <a href="https://stackoverflow.com/questions/4936620/using-strides-for-an-efficient-moving-average-filter">Using strides for an efficient moving average filter</a> but I don't see how to specify the stepsize there and how to collapse the window from the 3d to a continuous 2d array. Also this <a href="https://stackoverflow.com/questions/6822725/rolling-or-sliding-window-iterator-in-python">Rolling or sliding window iterator?</a> but that's in Python and I'm not sure how efficient that is. Also, it supports elements but does not join them together in the end if each element has multiple features.</p>