title: Fisher's Exact in scipy as new column using pandas
body: <p>Using ipython notebook, a pandas dataframe has 4 columns:  <strong>numerator1</strong>, <strong>numerator2</strong>, <strong>denominator1</strong> and <strong>denominator2</strong>.</p>
  
  <p>Without iterating through each record, I am trying to create a fifth column titled FishersExact.  I would like the value of the column to store the tuple returned by <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.fisher_exact.html#scipy.stats.fisher_exact" rel="nofollow">scipy.stats.fisher_exact</a> using values (or some derivation of the values) from each of the four columns as my inputs.</p>
  
  <pre><code>df['FishersExact'] = scipy.stats.fisher_exact( [[df.numerator1, df.numerator2],
  [df.denominator1 - df.numerator1 , df.denominator2 - df.numerator2]])
  </code></pre>
  
  <p>Returns:</p>
  
  <pre><code>/home/kevin/anaconda/lib/python2.7/site-packages/scipy/stats/stats.pyc in fisher_exact(table, alternative)
  2544     c = np.asarray(table, dtype=np.int64)  # int32 is not enough for the algorithm
  2545     if not c.shape == (2, 2):
  -&gt; 2546         raise ValueError("The input `table` must be of shape (2, 2).")
  2547 
  2548     if np.any(c &lt; 0):
  
  ValueError: The input `table` must be of shape (2, 2).
  </code></pre>
  
  <p>When I index only the first record of the dataframe:</p>
  
  <pre><code>odds,pval = scipy.stats.fisher_exact([[df.numerator1[0], df.numerator2[0]], 
  [df.denominator1[0] - df.numerator1[0], df.denominator2[0] -df.numerator2[0]]])
  </code></pre>
  
  <p>This is returned:</p>
  
  <pre><code>1.1825710754 0.581151431104
  </code></pre>
  
  <p>I'm essentially trying to emulate the arithmetic functionality similar to:</p>
  
  <pre><code>df['freqnum1denom1'] = df.numerator1 / df.denominator1
  </code></pre>
  
  <p>which returns a new column added to the dataframe where each records' frequency is in the new column.</p>
  
  <p>Probably missing something, any direction would be greatly appreciated, thank you!</p>