@@ -982,15 +982,15 @@ def _transform_should_cast(self, func_nm):
982
982
return (self .size ().fillna (0 ) > 0 ).any () and (func_nm not in
983
983
_cython_cast_blacklist )
984
984
985
- def _cython_transform (self , how , numeric_only = True ):
985
+ def _cython_transform (self , how , numeric_only = True , ** kwargs ):
986
986
output = collections .OrderedDict ()
987
987
for name , obj in self ._iterate_slices ():
988
988
is_numeric = is_numeric_dtype (obj .dtype )
989
989
if numeric_only and not is_numeric :
990
990
continue
991
991
992
992
try :
993
- result , names = self .grouper .transform (obj .values , how )
993
+ result , names = self .grouper .transform (obj .values , how , ** kwargs )
994
994
except NotImplementedError :
995
995
continue
996
996
except AssertionError as e :
@@ -1758,9 +1758,12 @@ def cumcount(self, ascending=True):
1758
1758
1759
1759
@Substitution (name = 'groupby' )
1760
1760
@Appender (_doc_template )
1761
- def rank (self , axis = 0 , * args , ** kwargs ):
1761
+ def rank (self , ties_method = 'average' , ascending = True , na_option = 'keep' ,
1762
+ pct = False , axis = 0 ):
1762
1763
"""Rank within each group"""
1763
- return self ._cython_transform ('rank' , ** kwargs )
1764
+ return self ._cython_transform ('rank' , ties_method = ties_method ,
1765
+ ascending = ascending , na_option = na_option ,
1766
+ pct = pct , axis = axis )
1764
1767
1765
1768
@Substitution (name = 'groupby' )
1766
1769
@Appender (_doc_template )
@@ -2237,7 +2240,8 @@ def wrapper(*args, **kwargs):
2237
2240
(how , dtype_str ))
2238
2241
return func , dtype_str
2239
2242
2240
- def _cython_operation (self , kind , values , how , axis , min_count = - 1 ):
2243
+ def _cython_operation (self , kind , values , how , axis , min_count = - 1 ,
2244
+ ** kwargs ):
2241
2245
assert kind in ['transform' , 'aggregate' ]
2242
2246
2243
2247
# can we do this operation with our cython functions
@@ -2329,7 +2333,8 @@ def _cython_operation(self, kind, values, how, axis, min_count=-1):
2329
2333
2330
2334
# TODO: min_count
2331
2335
result = self ._transform (
2332
- result , values , labels , func , is_numeric , is_datetimelike )
2336
+ result , values , labels , func , is_numeric , is_datetimelike ,
2337
+ ** kwargs )
2333
2338
2334
2339
if is_integer_dtype (result ):
2335
2340
mask = result == iNaT
@@ -2368,8 +2373,8 @@ def aggregate(self, values, how, axis=0, min_count=-1):
2368
2373
return self ._cython_operation ('aggregate' , values , how , axis ,
2369
2374
min_count = min_count )
2370
2375
2371
- def transform (self , values , how , axis = 0 ):
2372
- return self ._cython_operation ('transform' , values , how , axis )
2376
+ def transform (self , values , how , axis = 0 , ** kwargs ):
2377
+ return self ._cython_operation ('transform' , values , how , axis , ** kwargs )
2373
2378
2374
2379
def _aggregate (self , result , counts , values , comp_ids , agg_func ,
2375
2380
is_numeric , is_datetimelike , min_count = - 1 ):
@@ -2389,7 +2394,7 @@ def _aggregate(self, result, counts, values, comp_ids, agg_func,
2389
2394
return result
2390
2395
2391
2396
def _transform (self , result , values , comp_ids , transform_func ,
2392
- is_numeric , is_datetimelike ):
2397
+ is_numeric , is_datetimelike , ** kwargs ):
2393
2398
2394
2399
comp_ids , _ , ngroups = self .group_info
2395
2400
if values .ndim > 3 :
@@ -2403,7 +2408,7 @@ def _transform(self, result, values, comp_ids, transform_func,
2403
2408
transform_func (result [:, :, i ], values ,
2404
2409
comp_ids , is_datetimelike )
2405
2410
else :
2406
- transform_func (result , values , comp_ids , is_datetimelike )
2411
+ transform_func (result , values , comp_ids , is_datetimelike , ** kwargs )
2407
2412
2408
2413
return result
2409
2414
0 commit comments