Repository: pandas-dev/pandas
File: pandas/core/series.py (Python)

Code before:
        numpy.around : Round values of an np.array.
        DataFrame.round : Round values of a DataFrame.
        Series.dt.round : Round values of data to the specified freq.

        Notes
        -----
        For values exactly halfway between rounded decimal values, pandas rounds
        to the nearest even value (e.g. -0.5 and 0.5 round to 0.0, 1.5 and 2.5
        round to 2.0, etc.).

        Examples
        --------
        >>> s = pd.Series([-0.5, 0.1, 2.5, 1.3, 2.7])
        >>> s.round()
        0   -0.0
        1    0.0
        2    2.0
        3    1.0
        4    3.0
        dtype: float64
        """

        nv.validate_round(args, kwargs)

        if not is_numeric_dtype(self.dtype) and not is_object_dtype(self.dtype):
            raise TypeError(f"Cannot round with non-numeric dtype '{self.dtype}'")

        if len(self) == 0:
            return self.copy()

        if is_object_dtype(self.dtype):
            values = self._values
            result = lib.map_infer(values, lambda x: round(x, decimals), convert=False)
            return self._constructor(result, index=self.index, copy=False).__finalize__(
                self, method="round"
            )

        new_mgr = self._mgr.round(decimals=decimals)
        return self._constructor_from_mgr(new_mgr, axes=new_mgr.axes).__finalize__(
            self, method="round"
        )

    @overload
    def quantile(
        self, q: float = ..., interpolation: QuantileInterpolation = ...
    ) -> float: ...

    @overload
    def quantile(
        self,
        q: Sequence[float] | AnyArrayLike,

Review comment (bug):
There are  a few edge cases I think we should be a bit careful of handling here, namely categorical with floating values. I've opened https://github.com/pandas-dev/pandas/issues/63559 to propose deprecating. Can you remove these two lines and adjust the tests so that it's checking `round` is a no-op (just returns the input Series).

Code after:
        Series.dt.round : Round values of data to the specified freq.

        Notes
        -----
        For values exactly halfway between rounded decimal values, pandas rounds
        to the nearest even value (e.g. -0.5 and 0.5 round to 0.0, 1.5 and 2.5
        round to 2.0, etc.).

        Examples
        --------
        >>> s = pd.Series([-0.5, 0.1, 2.5, 1.3, 2.7])
        >>> s.round()
        0   -0.0
        1    0.0
        2    2.0
        3    1.0
        4    3.0
        dtype: float64
        """

        nv.validate_round(args, kwargs)

        if len(self) == 0:
            return self.copy()

        if is_object_dtype(self.dtype):
            values = self._values
            result = lib.map_infer(values, lambda x: round(x, decimals), convert=False)
            return self._constructor(result, index=self.index, copy=False).__finalize__(
                self, method="round"
            )
        new_mgr = self._mgr.round(decimals=decimals)
        return self._constructor_from_mgr(new_mgr, axes=new_mgr.axes).__finalize__(
            self, method="round"
        )

    @overload
    def quantile(
        self, q: float = ..., interpolation: QuantileInterpolation = ...
    ) -> float: ...

    @overload
    def quantile(
        self,
        q: Sequence[float] | AnyArrayLike,
        interpolation: QuantileInterpolation = ...,
    ) -> Series: ...

    @overload
    def quantile(
        self,