@@ -1776,7 +1776,29 @@ def cumcount(self, ascending=True):
1776
1776
@Appender (_doc_template )
1777
1777
def rank (self , method = 'average' , ascending = True , na_option = 'keep' ,
1778
1778
pct = False , axis = 0 ):
1779
- """Rank within each group"""
1779
+ """Provides the rank of values within each group
1780
+
1781
+ Parameters
1782
+ ----------
1783
+ method : {'average', 'min', 'max', 'first', 'dense'}, efault 'average'
1784
+ * average: average rank of group
1785
+ * min: lowest rank in group
1786
+ * max: highest rank in group
1787
+ * first: ranks assigned in order they appear in the array
1788
+ * dense: like 'min', but rank always increases by 1 between groups
1789
+ method : {'keep', 'top', 'bottom'}, default 'keep'
1790
+ * keep: leave NA values where they are
1791
+ * top: smallest rank if ascending
1792
+ * bottom: smallest rank if descending
1793
+ ascending : boolean, default True
1794
+ False for ranks by high (1) to low (N)
1795
+ pct : boolean, default False
1796
+ Compute percentage rank of data within each group
1797
+
1798
+ Returns
1799
+ -----
1800
+ DataFrame with ranking of values within each group
1801
+ """
1780
1802
return self ._cython_transform ('rank' , numeric_only = False ,
1781
1803
ties_method = method , ascending = ascending ,
1782
1804
na_option = na_option , pct = pct , axis = axis )
@@ -2198,11 +2220,12 @@ def get_group_levels(self):
2198
2220
'cummax' : 'group_cummax' ,
2199
2221
'rank' : {
2200
2222
'name' : 'group_rank' ,
2201
- 'f' : lambda func , a , b , c , d , ** kwargs : func (a , b , c , d ,
2202
- kwargs .get ('ties_method' , 'average' ),
2203
- kwargs .get ('ascending' , True ),
2204
- kwargs .get ('pct' , False ),
2205
- kwargs .get ('na_option' , 'keep' )
2223
+ 'f' : lambda func , a , b , c , d , ** kwargs : func (
2224
+ a , b , c , d ,
2225
+ kwargs .get ('ties_method' , 'average' ),
2226
+ kwargs .get ('ascending' , True ),
2227
+ kwargs .get ('pct' , False ),
2228
+ kwargs .get ('na_option' , 'keep' )
2206
2229
)
2207
2230
}
2208
2231
}
0 commit comments