title: Pandas groupby and calculate percentage change
body: <p>I take reference from <a href="https://stackoverflow.com/questions/23749342/how-to-create-rolling-percentage-for-groupby-dataframe">How to create rolling percentage for groupby DataFrame</a></p>
  
  <pre><code>import pandas as pd
  
  data = [
      ('product_a','1/31/2014',53)
      ,('product_b','1/31/2014',44)
      ,('product_c','1/31/2014',36)
      ,('product_a','11/30/2013',52)
      ,('product_b','11/30/2013',43)
      ,('product_c','11/30/2013',35)
      ,('product_a','3/31/2014',50)
      ,('product_b','3/31/2014',41)
      ,('product_c','3/31/2014',34)
      ,('product_a','12/31/2013',50)
      ,('product_b','12/31/2013',41)
      ,('product_c','12/31/2013',34)
      ,('product_a','2/28/2014',52)
      ,('product_b','2/28/2014',43)
      ,('product_c','2/28/2014',35)]
  
  product_df = pd.DataFrame( data, columns=['prod_desc','activity_month','prod_count'] )
  product_df.sort_values('activity_month', inplace = True, ascending=False) 
  product_df['pct_ch'] = product_df.groupby('prod_desc')['prod_count'].pct_change() + 1
  
  print(product_df)
  </code></pre>
  
  <p>however, I am not able to produce the output like the suggested answer.</p>
  
  <p>the answer produced     </p>
  
  <pre><code>    prod_desc activity_month  prod_count    pct_ch
  0   product_a      1/31/2014          53       NaN
  1   product_b      1/31/2014          44  0.830189
  2   product_c      1/31/2014          36  0.818182
  3   product_a     11/30/2013          52  1.444444
  4   product_b     11/30/2013          43  0.826923
  5   product_c     11/30/2013          35  0.813953
  9   product_a     12/31/2013          50  1.428571
  10  product_b     12/31/2013          41  0.820000
  11  product_c     12/31/2013          34  0.829268
  12  product_a      2/28/2014          52  1.529412
  13  product_b      2/28/2014          43  0.826923
  14  product_c      2/28/2014          35  0.813953
  6   product_a      3/31/2014          50  1.428571
  7   product_b      3/31/2014          41  0.820000
  8   product_c      3/31/2014          34  0.829268
  </code></pre>
  
  <p>Expected answer should be similar to below, percentage change should be calculated for every prod_desc (product_a, product_b and product_c) instead of one column only</p>
  
  <pre><code> product_desc activity_month  prod_count    pct_ch
  0    product_a     2014-01-01          53       NaN
  3    product_a     2014-02-01          26  0.490566
  6    product_a     2014-03-01          41  1.576923
  1    product_b     2014-01-01          42       NaN
  4    product_b     2014-02-01          48  1.142857
  7    product_b     2014-03-01          35  0.729167
  2    product_c     2014-01-01          38       NaN
  5    product_c     2014-02-01          39  1.026316
  8    product_c     2014-03-01          50  1.282051
  </code></pre>
  
  <p>Thank you in advance</p>