@final
def agg_series(self, obj: Series, func: Callable, preserve_dtype: bool=False) -> ArrayLike:
    '\n        Parameters\n        ----------\n        obj : Series\n        func : function taking a Series and returning a scalar-like\n        preserve_dtype : bool\n            Whether the aggregation is known to be dtype-preserving.\n\n        Returns\n        -------\n        np.ndarray or ExtensionArray\n        '
    if (len(obj) == 0):
        result = self._aggregate_series_pure_python(obj, func)
    elif (not isinstance(obj._values, np.ndarray)):
        result = self._aggregate_series_pure_python(obj, func)
        preserve_dtype = True
    else:
        result = self._aggregate_series_pure_python(obj, func)
    npvalues = lib.maybe_convert_objects(result, try_float=False)
    if preserve_dtype:
        out = maybe_cast_pointwise_result(npvalues, obj.dtype, numeric_only=True)
    else:
        out = npvalues
    return out
Parameters
----------
obj : Series
func : function taking a Series and returning a scalar-like
preserve_dtype : bool
    Whether the aggregation is known to be dtype-preserving.

Returns
-------
np.ndarray or ExtensionArray
@final
def agg_series(self, obj: Series, func: Callable, preserve_dtype: bool=False) -> ArrayLike:
    '\n        Parameters\n        ----------\n        obj : Series\n        func : function taking a Series and returning a scalar-like\n        preserve_dtype : bool\n            Whether the aggregation is known to be dtype-preserving.\n\n        Returns\n        -------\n        np.ndarray or ExtensionArray\n        '
    if (len(obj) == 0):
        result = self._aggregate_series_pure_python(obj, func)
    elif (not isinstance(obj._values, np.ndarray)):
        result = self._aggregate_series_pure_python(obj, func)
        preserve_dtype = True
    else:
        result = self._aggregate_series_pure_python(obj, func)
    npvalues = lib.maybe_convert_objects(result, try_float=False)
    if preserve_dtype:
        out = maybe_cast_pointwise_result(npvalues, obj.dtype, numeric_only=True)
    else:
        out = npvalues
    return out