title: How to t-test by group in a pandas dataframe?
body: <p>I have quite a huge pandas dataframe with many columns. The dataframe contains two groups. It is basically setup as follows:</p>
  
  <pre><code>import pandas as pd
  csv = [{"air" : 0.47,"co2" : 0.43 , "Group" : 1}, {"air" : 0.77,"co2" : 0.13 , "Group" : 1}, {"air" : 0.17,"co2" : 0.93 , "Group" : 2} ]
  df = pd.DataFrame(csv)
  </code></pre>
  
  <p>I want to perform a t-test paired t-test on <code>air</code> and <code>co2</code> thereby compare the two groups <code>Group = 1</code> and <code>Group = 2</code>.</p>
  
  <p>I have many many more columns than just <code>air</code> <code>co2</code>- hence, I would like to find a procedure that works for all columns int the dataframe. I believe, I could use <code>scipy.stats.ttest_rel</code> together with <code>pd.groupby</code> oder <code>apply</code>. How would that work? Thanks in advance /R</p>