title: Calculating average amount outstanding for customers live in consecutive months in a time series
body: <p>I have a dataframe that sums the $ amount of money that a customer has in their account during a particular month. If the customer has no money, the amount is simply 0. The dataframe looks like the below:</p>
  
  <pre><code>Customer    A       B       C       D       E        F   
  11/30/2015  0       1,000   0       0       5,000    0   
  12/31/2015  2,133   1,000   0       3,000   5,000    2,000
  1/31/2016   2,133   0       0       3,000   5,000    2,000
  2/29/2016   2,133   2,000   4,000   3,000   5,000    2,000
  3/31/2016   2,133   2,000   4,000   0       10,000   2,000
  4/30/2016   0       2,000   4,000   0       10,000   0   
  5/31/2016   0       2,000   4,000   0       10,000   0  
  </code></pre>
  
  <p>When a customer is live, they they have a nominal amount in their account for the particular month. Similarly, if they are live in the following month (or any month) they have a nominal amount in for that month also.</p>
  
  <p>I want to add a column at the end of the dataframe which calculates the average amount in customers accounts during the same month, but only for customers that were also live during the previous month</p>
  
  <p>I am trying to do some analysis on customer retention, and therefore I need the average amount outstanding to customers during this month, for customers that were live in the previous month also.</p>
  
  <p>The resulting dataframe would look like this:</p>
  
  <pre><code>Customer    A       B       C       D       E        F       Avg Outstanding consecutive Months
  11/30/2015  0       1,000   0       0       5,000    0       0
  12/31/2015  2,000   1,000   0       3,000   5,000    2,000   3,000
  1/31/2016   2,000   0       0       3,000   5,000    2,000   3,000
  2/29/2016   2,000   2,000   4,000   3,000   5,000    2,000   3,000
  3/31/2016   2,000   2,000   4,000   0       10,000   2,000   4,000
  4/30/2016   0       2,000   4,000   0       10,000   0       5,333
  5/31/2016   0       2,000   4,000   0       10,000   0       5,333
  </code></pre>