title: percentile rank in pandas in groups
body: <p>I can't quite figure out how to write function to accomplish a grouped percentile.  I have all teams from years 1985-2012 in a data frame; the first 10 are shown below: it's currently sorted by year.  I was looking to give a percentile for <code>LgRnk</code> grouped by <code>Year</code>.  So for instance, 23 LgRank (worst team) for 1985 would be a 100 percentile and a 1 LgRank (best team) for 1985 would be a 1 percentile. 30 LgRank (worst team) for 2010 would be 100 percentile, etc.   It needs to be grouped by year b/c of the differing number of <code>LgRnk</code>s. </p>
  
  <pre><code>    Team                WLPer   Year LgRnk   W  L
  19  Sacramento Kings    0.378   1985    18  31  51
  0   Atlanta Hawks       0.415   1985    17  34  48
  17  Phoenix Suns        0.439   1985    16  36  46
  4   Cleveland Cavaliers 0.439   1985    15  36  46
  13  Milwaukee Bucks     0.720   1985    3   59  23
  3   Chicago Bulls       0.463   1985    14  38  44
  16  Philadelphia 76ers  0.707   1985    4   58  24
  22  Washington Wizards  0.488   1985    13  40  42
  20  San Antonio Spurs   0.500   1985    12  41  41
  21  Utah Jazz           0.500   1985    11  41  41
  </code></pre>
  
  <p>I've tried creating a function using: <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.percentileofscore.html"><code>scipy.stats.percentileofscore</code></a>
  and I can't quite get it.</p>