title: pandas: t-test and p-value of month over month mean difference in aggregated dataframe using groupby function
body: <p>This is my first posted question, so please excuse if it doesn't look good.</p>
  
  <p>I have a source data file which I transform to the following dataframe using pandas groupby aggregation</p>
  
  <pre><code>pd.read_csv('R:/Python ETL/AGG7.csv', sep=',')
  
        Treatment     Month   stdev    n    avg
  0      AAAA       1/1/2016   1.92   309   7.57
  1      AAAA       2/1/2016   1.89    79   7.46
  2      AAAA       3/1/2016   2.25   158   7.20
  3      AAAA       4/1/2016   2.23    22   7.68
  4      BBBB       1/1/2016   2.04   175   7.10
  5      BBBB       2/1/2016   1.96    33   7.09
  6      BBBB       3/1/2016   2.02   110   7.32
  7      BBBB       4/1/2016   1.73    25   7.92
  8      CCCC       1/1/2016   2.42   111   7.40
  9      CCCC       2/1/2016   1.45    22   7.73
  10     CCCC       3/1/2016   2.44    21   6.95
  11     CCCC       4/1/2016   2.84    92   6.92
  </code></pre>
  
  <p>What I need is 2 additional columns with month over month difference (MoM diff) and p-value of T-tests of those differences.</p>
  
  <pre><code>MoM diff    pValue
  -0.11   0.35
  -0.26   0.62
   0.48   0.65
  
  -0.01   0.02
   0.23   0.44
   0.6    0.83
  
   0.33   0.46
  -0.78   0.79
  -0.03   0.04
  </code></pre>
  
  <p>The problem is that I cannot get them on the fly using pandas group by with scipy.stats ttest_ind function from original dataset and ttest_ind_from_stats function from the shown aggregated dataframe. I tried many different approaches, but with no success. Can anyone help, please?</p>