title: Calculate pvalue from pandas DataFrame
body: <p>I have a DataFrame stats with a Multindex and 8 samples (only two shown here) and 8 genes for each sample.   </p>
  
  <pre><code> In[13]:stats
      Out[13]: 
                         ARG/16S                                            \
                           count          mean           std           min   
      sample      gene                                                       
      Arnhem      IC        11.0  2.319050e-03  7.396130e-04  1.503150e-03   
                  Int1      11.0  7.243040e+00  6.848327e+00  1.364879e+00   
                  Sul1      11.0  3.968956e-03  9.186019e-04  2.499074e-03   
                  TetB       2.0  1.154748e-01  1.627663e-01  3.816936e-04   
                  TetM       4.0  1.083125e-04  5.185259e-05  5.189226e-05   
                  blaOXA     4.0  4.210963e-06  3.783235e-07  3.843571e-06   
                  ermB       4.0  4.111081e-05  7.894879e-06  3.288865e-05   
                  ermF       4.0  2.335210e-05  4.519758e-06  1.832037e-05   
      Basel       Aph3a      4.0  7.815592e-06  1.757242e-06  5.539389e-06   
                  IC        11.0  5.095161e-03  5.639278e-03  1.302205e-03   
                  Int1      12.0  1.333068e+01  1.872207e+01  4.988048e-02   
                  Sul1      11.0  1.618617e-02  1.988817e-02  2.970397e-03   
  </code></pre>
  
  <p>I'm trying to calculate the p-value (Students t-test) for each of these samples, comparing each of the genes between them.</p>
  
  <p>I've used scipy.stats.ttest_ind_from_stats but I managed to get the p-values for the different samples for one gene and only those of the samples neighboring each other.</p>
  
  <pre><code>Experiments = list(values1_16S['sample'].unique())
  for exp in Experiments:
      if Experiments.index(exp)&lt;len(Experiments)-1:
          second = Experiments[Experiments.index(exp)+1]
      else:
          second = Experiments[0]
      tstat, pvalue = scipy.stats.ttest_ind_from_stats(stats.loc[(exp,'Sul1')]['ARG/16S','mean'],
                                      stats.loc[(exp,'Sul1')]['ARG/16S','std'],
                                      stats.loc[(exp,'Sul1')]['ARG/16S','count'],
                                      stats.loc[(second,'Sul1')]['ARG/16S','mean'],
                                      stats.loc[(second,'Sul1')]['ARG/16S','std'],
                                      stats.loc[(second,'Sul1')]['ARG/16S','count'])
      d.append({'loc1':exp, 'loc2':second, 'pvalue':pvalue})
  
  
  stats_Sul1 = pd.DataFrame(d)
  stats_Sul1
  </code></pre>
  
  <p>How can I get the pvalues between ALL samples? And is there a way to do this for all genes at once without running the code one by one for each gene?</p>