title: Pandas percentrank based on groups within each index
body: <p>I have a dataframe, with a index which has dates (there are multiple same dates). For each date there are columns such as Price, Score, Category etc....</p>
  
  <p>I want 1 new column in the dataframe called pctrank.</p>
  
  <p>In the pctrank column, I want to calculate the percentile rank within each Category for each index level based on the Score values. Eg, for 1/24/2007 in below data, I would do a percent rank of all the scores of the supermarkets, and separately percent rank of all the score for all Reteraunts for that date, and then move to next date.</p>
  
  <p>As data set is large I would like it to be reasonable efficient.</p>
  
  <p>** EXAMPLE DATA BELOW **</p>
  
  <p>Subset of df:</p>
  
  <pre><code>            Category    SCORE
  1/24/2017   SuperMarket 12
  1/24/2017   Resteraunt  21
  1/24/2017   SuperMarket 13
  1/24/2017   SuperMarket 22
  1/24/2017   Resteraunt  27
  1/24/2017   SuperMarket 30
  1/24/2017   Resteraunt  34
  1/24/2017   Resteraunt  32
  1/24/2017   Resteraunt  21
  1/24/2017   Resteraunt  12
  1/24/2017   Bar         10
  1/24/2017   Bar          3
  1/24/2017   Bar         24
  1/25/2017   Resteraunt  32
  1/25/2017   Resteraunt  63
  1/25/2017   Resteraunt  32
  1/25/2017   Bar         12
  1/25/2017   Bar         32
  1/25/2017   Hospital    22
  1/25/2017   Hospital    12
  1/25/2017   Bar         10
  </code></pre>
  
  <p>Example output:</p>
  
  <pre><code>            Category    SCORE   Percnt rank    
  1/24/2017   SuperMarket 12         0    
  1/24/2017   Resteraunt  21         0.2  
  1/24/2017   SuperMarket 13        0.333 
  1/24/2017   SuperMarket 22        0.666  
  1/24/2017   Resteraunt  27       0.6   
  1/24/2017   SuperMarket 30         1    
  1/24/2017   Resteraunt  34         1    
  1/24/2017   Resteraunt  32       0.8   
  1/24/2017   Resteraunt  21       0.2    
  1/24/2017   Resteraunt  12       0  
  1/24/2017   Bar         10       0.5    
  1/24/2017   Bar          3       0   
  1/24/2017   Bar         24       1  
  1/25/2017   Resteraunt  32       0  
  1/25/2017   Resteraunt  63       1  
  1/25/2017   Resteraunt  32       0  
  1/25/2017   Bar         12      0.5 
  1/25/2017   Bar         32       1  
  1/25/2017   Hospital    22      1   
  1/25/2017   Hospital    12      0   
  1/25/2017   Bar         10     0    
  </code></pre>
  
  <p>Real data set has loads of dates and corresponding entries.</p>