title: Use groups in scipy.stats.kruskal similar to R cran kruskal.test
body: <p>I'm trying to replace some rpy2 code in a Python script with Python (scipy). In that context I need to replace a Kruskal-Wallis test (R:<code>kruskal.test()</code>) with  (Python:<code>scipy.stats.kruskal</code>).</p>
  
  <p><code>scipy.stats.kruskal</code> returns a similar H-statistic and P-value when comparing integers/floats only. However, I have some difficulty applying groups represented as strings. </p>
  
  <p>Below is a subsample of the data:</p>
  
  <pre><code>y = [4.33917022422, 2.96541899883, 6.70475220836, 9.19889096119, 2.14087398016,
       5.39520023918, 1.58443224287, 3.59625224078, 4.01998599966, 2.58058624352]
  x = ['High_O2', 'High_O2', 'High_O2', 'High_O2', 'Low_O2',
        'Low_O2',  'Low_O2',  'Low_O2',  'Mid_O2',  'Mid_O2']
  </code></pre>
  
  <p>In R one would just type:</p>
  
  <pre><code>kruskal.test(y,as.factor(x))
  </code></pre>
  
  <p>Doing the same thing in Python (2.7) using scipy (0.17):</p>
  
  <pre><code>from scipy import stats
  stats.kruskal(y,x)
  </code></pre>
  
  <p>However, I get very low p values <code>(p&lt;e-07)</code> and quite high H-statistics <code>(26)</code> when using scipy, which is incorrect. I have tried to replace the <code>x</code> list with <code>{0,1,2}</code> with no improvement.</p>
  
  <p>How can I tell scipy to treat <code>x</code> as groups during the ranking?</p>