diff --git a/pandas/core/apply.py b/pandas/core/apply.py index db4203e5158ef..4e7fbcb9efeb4 100644 --- a/pandas/core/apply.py +++ b/pandas/core/apply.py @@ -98,22 +98,6 @@ def frame_apply( ) -def series_apply( - obj: Series, - func: AggFuncType, - convert_dtype: bool = True, - args=None, - kwargs=None, -) -> SeriesApply: - return SeriesApply( - obj, - func, - convert_dtype, - args, - kwargs, - ) - - class Apply(metaclass=abc.ABCMeta): axis: int diff --git a/pandas/core/series.py b/pandas/core/series.py index 5fece72ccddca..e4b4826e4561c 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -96,7 +96,7 @@ ops, ) from pandas.core.accessor import CachedAccessor -from pandas.core.apply import series_apply +from pandas.core.apply import SeriesApply from pandas.core.arrays import ExtensionArray from pandas.core.arrays.categorical import CategoricalAccessor from pandas.core.arrays.sparse import SparseAccessor @@ -4003,7 +4003,7 @@ def aggregate(self, func=None, axis=0, *args, **kwargs): if func is None: func = dict(kwargs.items()) - op = series_apply(self, func, args=args, kwargs=kwargs) + op = SeriesApply(self, func, convert_dtype=False, args=args, kwargs=kwargs) result = op.agg() return result @@ -4019,7 +4019,9 @@ def transform( ) -> FrameOrSeriesUnion: # Validate axis argument self._get_axis_number(axis) - result = series_apply(self, func=func, args=args, kwargs=kwargs).transform() + result = SeriesApply( + self, func=func, convert_dtype=True, args=args, kwargs=kwargs + ).transform() return result def apply( @@ -4131,7 +4133,7 @@ def apply( Helsinki 2.484907 dtype: float64 """ - return series_apply(self, func, convert_dtype, args, kwargs).apply() + return SeriesApply(self, func, convert_dtype, args, kwargs).apply() def _reduce( self,