@@ -985,15 +985,7 @@ def agg_series(self, obj: Series, func: F) -> tuple[ArrayLike, np.ndarray]:
985
985
# Preempt TypeError in _aggregate_series_fast
986
986
return self ._aggregate_series_pure_python (obj , func )
987
987
988
- try :
989
- return self ._aggregate_series_fast (obj , func )
990
- except ValueError as err :
991
- if "Must produce aggregated value" in str (err ):
992
- # raised in libreduction
993
- pass
994
- else :
995
- raise
996
- return self ._aggregate_series_pure_python (obj , func )
988
+ return self ._aggregate_series_fast (obj , func )
997
989
998
990
def _aggregate_series_fast (
999
991
self , obj : Series , func : F
@@ -1023,9 +1015,10 @@ def _aggregate_series_pure_python(self, obj: Series, func: F):
1023
1015
result = np .empty (ngroups , dtype = "O" )
1024
1016
initialized = False
1025
1017
1018
+ # equiv: splitter = self._get_splitter(obj, axis=0)
1026
1019
splitter = get_splitter (obj , group_index , ngroups , axis = 0 )
1027
1020
1028
- for label , group in enumerate (splitter ):
1021
+ for i , group in enumerate (splitter ):
1029
1022
1030
1023
# Each step of this loop corresponds to
1031
1024
# libreduction._BaseGrouper._apply_to_group
@@ -1034,11 +1027,11 @@ def _aggregate_series_pure_python(self, obj: Series, func: F):
1034
1027
1035
1028
if not initialized :
1036
1029
# We only do this validation on the first iteration
1037
- libreduction .check_result_array (res , 0 )
1030
+ libreduction .check_result_array (res )
1038
1031
initialized = True
1039
1032
1040
- counts [label ] = group .shape [0 ]
1041
- result [label ] = res
1033
+ counts [i ] = group .shape [0 ]
1034
+ result [i ] = res
1042
1035
1043
1036
npvalues = lib .maybe_convert_objects (result , try_float = False )
1044
1037
out = maybe_cast_pointwise_result (npvalues , obj .dtype , numeric_only = True )
0 commit comments