title: groupby for pandas data frame gives wrong results
body: <p>I am trying to replicate a paper whose code was written in Stata for my course project using Python. I have difficulty replicating the results from a collapse command in their do-file. The corresponding line in the do-file is </p>
  
  <pre><code>collapse lexptot, by(clwpop right)
  </code></pre>
  
  <p>while I have </p>
  
  <pre><code>df.groupby(['cwpop', 'right'])['lexptot'].agg(['mean'])
  </code></pre>
  
  <p>The <code>lexptot</code> variable is the logarithm of a variable '<code>exptot</code>' which I calculated previously using <code>np.log(dfs['exptot])</code>.</p>
  
  <p>Does anyone have an idea what is going wrong here? The means I calculate are typically around 1.5 higher than the means calculated in Stata.</p>