@@ -994,15 +994,15 @@ def _transform_should_cast(self, func_nm):
994
994
return (self .size ().fillna (0 ) > 0 ).any () and (func_nm not in
995
995
_cython_cast_blacklist )
996
996
997
- def _cython_transform (self , how , numeric_only = True ):
997
+ def _cython_transform (self , how , numeric_only = True , ** kwargs ):
998
998
output = collections .OrderedDict ()
999
999
for name , obj in self ._iterate_slices ():
1000
1000
is_numeric = is_numeric_dtype (obj .dtype )
1001
1001
if numeric_only and not is_numeric :
1002
1002
continue
1003
1003
1004
1004
try :
1005
- result , names = self .grouper .transform (obj .values , how )
1005
+ result , names = self .grouper .transform (obj .values , how , ** kwargs )
1006
1006
except NotImplementedError :
1007
1007
continue
1008
1008
except AssertionError as e :
@@ -1770,9 +1770,12 @@ def cumcount(self, ascending=True):
1770
1770
1771
1771
@Substitution (name = 'groupby' )
1772
1772
@Appender (_doc_template )
1773
- def rank (self , axis = 0 , * args , ** kwargs ):
1773
+ def rank (self , ties_method = 'average' , ascending = True , na_option = 'keep' ,
1774
+ pct = False , axis = 0 ):
1774
1775
"""Rank within each group"""
1775
- return self ._cython_transform ('rank' , ** kwargs )
1776
+ return self ._cython_transform ('rank' , ties_method = ties_method ,
1777
+ ascending = ascending , na_option = na_option ,
1778
+ pct = pct , axis = axis )
1776
1779
1777
1780
@Substitution (name = 'groupby' )
1778
1781
@Appender (_doc_template )
@@ -2249,7 +2252,8 @@ def wrapper(*args, **kwargs):
2249
2252
(how , dtype_str ))
2250
2253
return func , dtype_str
2251
2254
2252
- def _cython_operation (self , kind , values , how , axis , min_count = - 1 ):
2255
+ def _cython_operation (self , kind , values , how , axis , min_count = - 1 ,
2256
+ ** kwargs ):
2253
2257
assert kind in ['transform' , 'aggregate' ]
2254
2258
2255
2259
# can we do this operation with our cython functions
@@ -2341,7 +2345,8 @@ def _cython_operation(self, kind, values, how, axis, min_count=-1):
2341
2345
2342
2346
# TODO: min_count
2343
2347
result = self ._transform (
2344
- result , values , labels , func , is_numeric , is_datetimelike )
2348
+ result , values , labels , func , is_numeric , is_datetimelike ,
2349
+ ** kwargs )
2345
2350
2346
2351
if is_integer_dtype (result ):
2347
2352
mask = result == iNaT
@@ -2380,8 +2385,8 @@ def aggregate(self, values, how, axis=0, min_count=-1):
2380
2385
return self ._cython_operation ('aggregate' , values , how , axis ,
2381
2386
min_count = min_count )
2382
2387
2383
- def transform (self , values , how , axis = 0 ):
2384
- return self ._cython_operation ('transform' , values , how , axis )
2388
+ def transform (self , values , how , axis = 0 , ** kwargs ):
2389
+ return self ._cython_operation ('transform' , values , how , axis , ** kwargs )
2385
2390
2386
2391
def _aggregate (self , result , counts , values , comp_ids , agg_func ,
2387
2392
is_numeric , is_datetimelike , min_count = - 1 ):
@@ -2401,7 +2406,7 @@ def _aggregate(self, result, counts, values, comp_ids, agg_func,
2401
2406
return result
2402
2407
2403
2408
def _transform (self , result , values , comp_ids , transform_func ,
2404
- is_numeric , is_datetimelike ):
2409
+ is_numeric , is_datetimelike , ** kwargs ):
2405
2410
2406
2411
comp_ids , _ , ngroups = self .group_info
2407
2412
if values .ndim > 3 :
@@ -2415,7 +2420,7 @@ def _transform(self, result, values, comp_ids, transform_func,
2415
2420
transform_func (result [:, :, i ], values ,
2416
2421
comp_ids , is_datetimelike )
2417
2422
else :
2418
- transform_func (result , values , comp_ids , is_datetimelike )
2423
+ transform_func (result , values , comp_ids , is_datetimelike , ** kwargs )
2419
2424
2420
2425
return result
2421
2426
0 commit comments