title: Annualized Return in Pandas
body: <p>I am seeking to confirm that my representation of the annualized return formula (using monthly returns) is optimal.</p>
  
  <p>The annualized return formula I am using (where M is a monthly return and D is the total count of monthly returns) where the count of monthly returns is greater than 12 is as follows:</p>
  
  <p><img src="https://chart.googleapis.com/chart?cht=tx&amp;chl=%R_%7BA%7D%20%3D%20(1%20%2B%20R_%7BM%7D)%5E%7B12%2FD%7D" alt="formula"></p>
  
  <p>Alternatively, the this would change in the case of the monthly return count being less than 12:</p>
  
  <p><img src="https://chart.googleapis.com/chart?cht=tx&amp;chl=%R_%7BA%7D%20%3D%20(1%20%2B%20R_%7BM%7D)%5E%7B1%5Cwedge%2012%2FD%7D" alt="formula"></p>
  
  <p>Here is my representation of this formula in Pandas:</p>
  
  <pre><code>ann_return = observations.apply(lambda y: y.apply(lambda x: x+1))
  ann_return = (ann_return.prod() ** (np.min(12/len(ann_return.index.values)) if len(ann_return.index.values) &gt; 12 else 12/len(ann_return.index.values)))-1
  </code></pre>