title: Using Pandas .diff() on a time series column with a groupby
body: <p>I have a <code>CSV</code> file of customer purchases in no particular order that I read into a <code>Pandas</code> <code>Dataframe</code>. I'd like to add a column for each purchase and show how much time has passed since the last purchase, grouped by customer. I'm not sure where it's getting the differences, but they are much too large (even if in seconds).</p>
  
  <p>CSV:</p>
  
  <pre><code>Customer Id,Purchase Date
  4543,1/1/2015
  4543,2/5/2015
  4543,3/15/2015
  2322,1/1/2015
  2322,3/1/2015
  2322,2/1/2015
  </code></pre>
  
  <p>Python:</p>
  
  <pre><code>import pandas as pd
  import time
  start = time.time()
  data = pd.read_csv('data.csv', low_memory=False)
  data = data.sort_values(by=['Customer Id', 'Purchase Date'])
  data['Purchase Date'] = pd.to_datetime(data['Purchase Date'])
  data['Purchase Difference'] = (data.groupby(['Customer Id'])['Purchase Date']
                           .diff()
                           .fillna('-')
                         )
  print data
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>    Customer Id Purchase Date Purchase Difference
  3         2322    2015-01-01                   -
  5         2322    2015-02-01    2678400000000000
  4         2322    2015-03-01    2419200000000000
  0         4543    2015-01-01                   -
  1         4543    2015-02-05    3024000000000000
  2         4543    2015-03-15    328320000000000
  </code></pre>
  
  <p>Desired Output:</p>
  
  <pre><code>   Customer Id Purchase Date  Purchase Difference
  3         2322    2015-01-01                  -
  5         2322    2015-02-01              31 days
  4         2322    2015-03-01              28 days
  0         4543    2015-01-01                  -
  1         4543    2015-02-05              35 days
  2         4543    2015-03-15              38 days
  </code></pre>