title: Using Pandas groupby to calculate many slopes
body: <p>Some illustrative data in a DataFrame (MultiIndex) format:</p>
  
  <p><code>
  |entity| year |value|
  +------+------+-----+
  |  a   | 1999 |  2  |
  |      | 2004 |  5  |
  |  b   | 2003 |  3  |
  |      | 2007 |  2  |
  |      | 2014 |  7  |</code></p>
  
  <p>I would like to calculate the slope using <code>scipy.stats.linregress</code> for each entity <code>a</code> and <code>b</code> in the above example. I tried using <code>groupby</code> on the first column, following the <a href="http://pandas.pydata.org/pandas-docs/stable/groupby.html" rel="nofollow">split-apply-combine advice</a>, but it seems problematic since it's expecting one <code>Series</code> of values (<code>a</code> and <code>b</code>), whereas I need to operate on the two columns on the right.</p>
  
  <p>This is easily done in R via <code>plyr</code>, not sure how to approach it in pandas.</p>