title: How to do expanding window by group in pandas
body: <p>In particular I want to do an expanding average of the difference between two dates in a series, by group. So if I have something like this:</p>
  
  <pre><code>Period    Group    dates
    1         A      2010-07-01
    2         A      2010-07-13
    3         A      2010-07-13
    4         A      2010-07-21
    1         B      2000-08-20
    2         B      2000-08-15
  </code></pre>
  
  <p>I would get:</p>
  
  <pre><code>Period    Group    cumulative average of differences
    1         A        0
    2         A        12/2
    3         A        12/3
    4         A        20/4
    1         B        0
    2         B       -5/2
  </code></pre>