@@ -201,7 +201,7 @@ def apply(self, f, data: FrameOrSeries, axis: int = 0):
201
201
continue
202
202
203
203
# group might be modified
204
- group_axes = _get_axes ( group )
204
+ group_axes = group . axes
205
205
res = f (group )
206
206
if not _is_indexed_like (res , group_axes ):
207
207
mutated = True
@@ -358,40 +358,33 @@ def _is_builtin_func(self, arg):
358
358
def _get_cython_function (self , kind : str , how : str , values , is_numeric : bool ):
359
359
360
360
dtype_str = values .dtype .name
361
+ ftype = self ._cython_functions [kind ][how ]
361
362
362
- def get_func (fname ):
363
- # see if there is a fused-type version of function
364
- # only valid for numeric
365
- f = getattr (libgroupby , fname , None )
366
- if f is not None and is_numeric :
367
- return f
368
-
369
- # otherwise find dtype-specific version, falling back to object
370
- for dt in [dtype_str , "object" ]:
371
- f2 = getattr (
372
- libgroupby ,
373
- "{fname}_{dtype_str}" .format (fname = fname , dtype_str = dt ),
374
- None ,
375
- )
376
- if f2 is not None :
377
- return f2
378
-
379
- if hasattr (f , "__signatures__" ):
380
- # inspect what fused types are implemented
381
- if dtype_str == "object" and "object" not in f .__signatures__ :
382
- # return None so we get a NotImplementedError below
383
- # instead of a TypeError at runtime
384
- return None
363
+ # see if there is a fused-type version of function
364
+ # only valid for numeric
365
+ f = getattr (libgroupby , ftype , None )
366
+ if f is not None and is_numeric :
385
367
return f
386
368
387
- ftype = self ._cython_functions [kind ][how ]
369
+ # otherwise find dtype-specific version, falling back to object
370
+ for dt in [dtype_str , "object" ]:
371
+ f2 = getattr (libgroupby , f"{ ftype } _{ dt } " , None )
372
+ if f2 is not None :
373
+ return f2
374
+
375
+ if hasattr (f , "__signatures__" ):
376
+ # inspect what fused types are implemented
377
+ if dtype_str == "object" and "object" not in f .__signatures__ :
378
+ # disallow this function so we get a NotImplementedError below
379
+ # instead of a TypeError at runtime
380
+ f = None
388
381
389
- func = get_func ( ftype )
382
+ func = f
390
383
391
384
if func is None :
392
385
raise NotImplementedError (
393
- "function is not implemented for this dtype: "
394
- "[how->{how},dtype->{dtype_str}]" . format ( how = how , dtype_str = dtype_str )
386
+ f "function is not implemented for this dtype: "
387
+ f "[how->{ how } ,dtype->{ dtype_str } ]"
395
388
)
396
389
397
390
return func
@@ -843,13 +836,6 @@ def agg_series(self, obj: Series, func):
843
836
return grouper .get_result ()
844
837
845
838
846
- def _get_axes (group ):
847
- if isinstance (group , Series ):
848
- return [group .index ]
849
- else :
850
- return group .axes
851
-
852
-
853
839
def _is_indexed_like (obj , axes ) -> bool :
854
840
if isinstance (obj , Series ):
855
841
if len (axes ) > 1 :
0 commit comments