title: Pandas Groupby Geometric Average?
body: <p>I'm trying to calculate the stock returns for my portfolio which requires &quot;geometrically averaging&quot; the percentages by year.</p>
  <p>For simplicity, I have a dataframe that looks likes this:</p>
  <p>Date        Returns</p>
  <p>2013-06-01    1%<br />
  2013-07-01    5%<br />
  2013-08-01   -4%<br />
  2014-01-01   12%<br />
  2014-02-01   -9%</p>
  <p>I'd like the output to show:</p>
  <p>Date   Geo Return
  2013   1.8%
  2015   1.9%</p>
  <p>Which is derived by: (1+.01)(1+.05)(1+-.04) = 1.8%</p>
  <p>I am able to use the groupby function by year, but it only sums for me and I can't get the geometric average to work. Could someone please help?</p>
  <p>Thanks!</p>