title: How to rank within a group in Python?
body: <p>I have the following data frame</p>
  
  <p>A ></p>
  
  <pre><code>  Bucket    C   Count
  PL14    XY23081063  706
  PL14    XY23326234  15
  PL14    XY23081062  1
  PL14    XY23143628  1
  FZ595   XY23157633  353
  FZ595   XY23683174  107
  XM274   XY23681818  139
  XM274   XY23681819  108
  </code></pre>
  
  <p>Now I want to insert a new column "Bucket_Rank" which ranks "C" under each "Bucket" based on descending value of "Count"</p>
  
  <p>required output  : 
  B ></p>
  
  <pre><code>Bucket  C   Count   Bucket_Rank
  PL14    XY23081063  706 1
  PL14    XY23326234  15  2
  PL14    XY23081062  1   3
  PL14    XY23143628  1   4
  FZ595   XY23157633  353 1
  FZ595   XY23683174  107 2
  XM274   XY23681818  139 1
  XM274   XY23681819  108 2
  </code></pre>
  
  <p>I tried the solution given in the following link </p>
  
  <p><a href="https://stackoverflow.com/questions/33899369/ranking-order-per-group-in-pandas?rq=1">Ranking order per group in Pandas</a></p>
  
  <p>command :  B["Bucket_Rank"] = A.groupby("Bucket ")["Count"].rank("dense", ascending=False)</p>
  
  <p>but its giving me the following error ..</p>
  
  <pre><code>TypeError: rank() got multiple values for argument 'axis'
  
  During handling of the above exception, another exception occurred:
  
  ValueError      
  </code></pre>
  
  <p>Help appreciated...TIA</p>