title: Pandas rolling sum, variating length
body: <p>I will try and explain the problem I am currently having concerning cumulative sums on DataFrames in Python, and hopefully you'll grasp it!</p>
  
  <p>Given a pandas DataFrame <code>df</code> with a column <code>returns</code> as such:</p>
  
  <pre><code>              returns
  Date                                                          
  2014-12-10    0.0000
  2014-12-11    0.0200
  2014-12-12    0.0500
  2014-12-15    -0.0200
  2014-12-16    0.0000
  </code></pre>
  
  <p>Applying a cumulative sum on this DataFrame is easy, just using e.g. <code>df.cumsum()</code>. But is it possible to apply a cumulative sum every <code>X</code> days (or data points) say, yielding only the cumulative sum of the last <code>Y</code> days (data points).</p>
  
  <p>Clarification: Given daily data as above, how do I get the accumulated sum of the last <code>Y</code> days, re-evaluated (from zero) every <code>X</code> days?</p>
  
  <p>Hope its clear enough,</p>
  
  <p>Thanks,
  N</p>