title: Python overlapping sliding dataframe
body: <p>I'm implementing a machine learning algorithm and I'm extracting features out of a dataframe. I obviously need overlapping windows. Suppose the DataFrame looks like this</p>
  
  <pre><code> x     y   z
   12.1  11  0.5
   12.2  10  0.3
   12.4  11  0.5
   12.8  12  0.4
   13.1  13  0.4
   14.7  14  0.5
   15.2  14  0.6
   15.3  13  0.5
   17.3  14  0.5
   18.2  15  0.4
   16.1  16  0.2
   15.0  17  0.1
  </code></pre>
  
  <p>But in reality a lot larger (thousands of samples). I now want a list of dataframes where each <code>DataFrame</code> is of length <code>ws</code> (here 150) and to have <code>step</code> (stride) of 60.</p>
  
  <p>This is what I got </p>
  
  <pre><code>r = np.arange(len(df))
  s = r[::step]
  return [df.iloc[k:k+ws] for k in s]
  </code></pre>
  
  <p>This works reasonably good but there's still one problem. The last 1,2 or 3 frames might not have length <code>ws</code>. I also cannot just discard the last 3 since there's sometimes only one with a length smaller then <code>ws</code>. So the <code>s</code> variable just keeps all the start indices, I'd need a way to have only the start indices where <code>start_index + step &lt; len(df)</code>. Unless of course, there are better and or faster ways for this (maybe a library). All existing documentation only talks about simple arrays.</p>