title: Why does t-test in Python (scipy, statsmodels) give results different from R, Stata, or Excel?
body: <p>(problem resolved; x,y and s1,s2 were of different size)</p>
  
  <p>in R:</p>
  
  <pre><code>x &lt;- c(373,398,245,272,238,241,134,410,158,125,198,252,577,272,208,260)
  y &lt;- c(411,471,320,364,311,390,163,424,228,144,246,371,680,384,279,303)
  t.test(x,y)
  t = -1.6229, df = 29.727, p-value = 0.1152
  </code></pre>
  
  <p>Same numbers are obtained in STATA and Excel</p>
  
  <pre><code>t.test(x,y,alternative="less")
  t = -1.6229, df = 29.727, p-value = 0.05758
  </code></pre>
  
  <p>I cannot replicate the same result using either statsmodels.stats.weightstats.ttest_ind or scipy.stats.ttest_ind no matter which options I try.</p>
  
  <pre><code>statsmodels.stats.weightstats.ttest_ind(s1,s2,alternative="two-sided",usevar="unequal")
  (-1.8912081781378358, 0.066740317997990656, 35.666557473974343)
  
  scipy.stats.ttest_ind(s1,s2,equal_var=False)
  (array(-1.8912081781378338), 0.066740317997990892)
  
  scipy.stats.ttest_ind(s1,s2,equal_var=True)
  (array(-1.8912081781378338), 0.066664507499812745)
  </code></pre>
  
  <p>There must be thousands of people who use Python to calculate t-test. Are we all getting incorrect results? (I typically rely on Python but this time I checked my results with STATA).</p>