@@ -923,7 +923,8 @@ def _cython_operation(
923
923
** kwargs ,
924
924
)
925
925
926
- def agg_series (self , obj : Series , func : F ):
926
+ @final
927
+ def agg_series (self , obj : Series , func : F ) -> tuple [ArrayLike , np .ndarray ]:
927
928
# Caller is responsible for checking ngroups != 0
928
929
assert self .ngroups != 0
929
930
@@ -952,8 +953,9 @@ def agg_series(self, obj: Series, func: F):
952
953
raise
953
954
return self ._aggregate_series_pure_python (obj , func )
954
955
955
- @final
956
- def _aggregate_series_fast (self , obj : Series , func : F ):
956
+ def _aggregate_series_fast (
957
+ self , obj : Series , func : F
958
+ ) -> tuple [ArrayLike , np .ndarray ]:
957
959
# At this point we have already checked that
958
960
# - obj.index is not a MultiIndex
959
961
# - obj is backed by an ndarray, not ExtensionArray
@@ -1157,18 +1159,14 @@ def groupings(self) -> list[grouper.Grouping]:
1157
1159
for lvl , name in zip (self .levels , self .names )
1158
1160
]
1159
1161
1160
- def agg_series (self , obj : Series , func : F ):
1161
- # Caller is responsible for checking ngroups != 0
1162
- assert self .ngroups != 0
1163
- assert len (self .bins ) > 0 # otherwise we'd get IndexError in get_result
1164
-
1165
- if is_extension_array_dtype (obj .dtype ):
1166
- # preempt SeriesBinGrouper from raising TypeError
1167
- return self ._aggregate_series_pure_python (obj , func )
1168
-
1169
- elif obj .index ._has_complex_internals :
1170
- return self ._aggregate_series_pure_python (obj , func )
1171
-
1162
+ def _aggregate_series_fast (
1163
+ self , obj : Series , func : F
1164
+ ) -> tuple [ArrayLike , np .ndarray ]:
1165
+ # At this point we have already checked that
1166
+ # - obj.index is not a MultiIndex
1167
+ # - obj is backed by an ndarray, not ExtensionArray
1168
+ # - ngroups != 0
1169
+ # - len(self.bins) > 0
1172
1170
grouper = libreduction .SeriesBinGrouper (obj , func , self .bins )
1173
1171
return grouper .get_result ()
1174
1172
0 commit comments