title: How to increment a row count in groupby in DataFrame
body: <p>I need to calculate the number of activity_months for each product in a pandas DataFrame. Here is my data and code so far:</p>
  
  <pre><code>from pandas import DataFrame
  from datetime import datetime
  data = [
  ('product_a','08/31/2013')
  ,('product_b','08/31/2013')
  ,('product_c','08/31/2013')
  ,('product_a','09/30/2013')
  ,('product_b','09/30/2013')
  ,('product_c','09/30/2013')
  ,('product_a','10/31/2013')
  ,('product_b','10/31/2013')
  ,('product_c','10/31/2013')
  ]
  
  product_df = DataFrame( data, columns=['prod_desc','activity_month'])
  
  for index, row in product_df.iterrows():
    row['activity_month']= datetime.strptime(row['activity_month'],'%m/%d/%Y')
    product_df.loc[index, 'activity_month'] = datetime.strftime(row['activity_month'],'%Y-%m-%d')
  
  product_df = product_df.sort(['prod_desc','activity_month'])
  
  product_df['month_num'] = product_df.groupby(['prod_desc']).size()
  </code></pre>
  
  <p>However, this returns NaNs for month_num. </p>
  
  <p>Here is what I want to get:</p>
  
  <pre><code>prod_desc    activity_month   month_num 
  product_a       2014-08-31         1 
  product_a       2014-09-30         2         
  product_a       2014-10-31         3         
  product_b       2014-08-31         1 
  product_b       2014-09-30         2         
  product_b       2014-10-31         3         
  product_c       2014-08-31         1 
  product_c       2014-09-30         2         
  product_c       2014-10-31         3     
  </code></pre>