@@ -968,28 +968,28 @@ def _cython_operation(
968968 )
969969
970970 @final
971- def agg_series (self , obj : Series , func : F ) -> tuple [ ArrayLike , np . ndarray ] :
971+ def agg_series (self , obj : Series , func : F ) -> ArrayLike :
972972 # Caller is responsible for checking ngroups != 0
973973 assert self .ngroups != 0
974974
975975 cast_back = True
976976 if len (obj ) == 0 :
977977 # SeriesGrouper would raise if we were to call _aggregate_series_fast
978- result , counts = self ._aggregate_series_pure_python (obj , func )
978+ result = self ._aggregate_series_pure_python (obj , func )
979979
980980 elif not isinstance (obj ._values , np .ndarray ):
981981 # _aggregate_series_fast would raise TypeError when
982982 # calling libreduction.Slider
983983 # In the datetime64tz case it would incorrectly cast to tz-naive
984984 # TODO: can we get a performant workaround for EAs backed by ndarray?
985- result , counts = self ._aggregate_series_pure_python (obj , func )
985+ result = self ._aggregate_series_pure_python (obj , func )
986986
987987 elif obj .index ._has_complex_internals :
988988 # Preempt TypeError in _aggregate_series_fast
989- result , counts = self ._aggregate_series_pure_python (obj , func )
989+ result = self ._aggregate_series_pure_python (obj , func )
990990
991991 else :
992- result , counts = self ._aggregate_series_fast (obj , func )
992+ result = self ._aggregate_series_fast (obj , func )
993993 cast_back = False
994994
995995 npvalues = lib .maybe_convert_objects (result , try_float = False )
@@ -998,11 +998,11 @@ def agg_series(self, obj: Series, func: F) -> tuple[ArrayLike, np.ndarray]:
998998 out = maybe_cast_pointwise_result (npvalues , obj .dtype , numeric_only = True )
999999 else :
10001000 out = npvalues
1001- return out , counts
1001+ return out
1002+
1003+ def _aggregate_series_fast (self , obj : Series , func : F ) -> np .ndarray :
1004+ # -> np.ndarray[object]
10021005
1003- def _aggregate_series_fast (
1004- self , obj : Series , func : F
1005- ) -> tuple [ArrayLike , np .ndarray ]:
10061006 # At this point we have already checked that
10071007 # - obj.index is not a MultiIndex
10081008 # - obj is backed by an ndarray, not ExtensionArray
@@ -1017,11 +1017,12 @@ def _aggregate_series_fast(
10171017 obj = obj .take (indexer )
10181018 ids = ids .take (indexer )
10191019 sgrouper = libreduction .SeriesGrouper (obj , func , ids , ngroups )
1020- result , counts = sgrouper .get_result ()
1021- return result , counts
1020+ result , _ = sgrouper .get_result ()
1021+ return result
10221022
10231023 @final
1024- def _aggregate_series_pure_python (self , obj : Series , func : F ):
1024+ def _aggregate_series_pure_python (self , obj : Series , func : F ) -> np .ndarray :
1025+ # -> np.ndarray[object]
10251026 ids , _ , ngroups = self .group_info
10261027
10271028 counts = np .zeros (ngroups , dtype = int )
@@ -1046,7 +1047,7 @@ def _aggregate_series_pure_python(self, obj: Series, func: F):
10461047 counts [i ] = group .shape [0 ]
10471048 result [i ] = res
10481049
1049- return result , counts
1050+ return result
10501051
10511052
10521053class BinGrouper (BaseGrouper ):
@@ -1204,16 +1205,17 @@ def groupings(self) -> list[grouper.Grouping]:
12041205 ping = grouper .Grouping (lev , lev , in_axis = False , level = None , name = lev .name )
12051206 return [ping ]
12061207
1207- def _aggregate_series_fast (
1208- self , obj : Series , func : F
1209- ) -> tuple [ ArrayLike , np . ndarray ]:
1208+ def _aggregate_series_fast (self , obj : Series , func : F ) -> np . ndarray :
1209+ # -> np.ndarray[object]
1210+
12101211 # At this point we have already checked that
12111212 # - obj.index is not a MultiIndex
12121213 # - obj is backed by an ndarray, not ExtensionArray
12131214 # - ngroups != 0
12141215 # - len(self.bins) > 0
12151216 sbg = libreduction .SeriesBinGrouper (obj , func , self .bins )
1216- return sbg .get_result ()
1217+ result , _ = sbg .get_result ()
1218+ return result
12171219
12181220
12191221def _is_indexed_like (obj , axes , axis : int ) -> bool :
0 commit comments