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

Code before:
        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)
        # Handle empty Series gracefully
        if len(self) == 0:
            return self.copy()

        if self.dtype == "object":
            # Delegate to Python's built-in round() for object dtype
            values = self._values

            # lib.map_infer is the fastest way to apply element-wise operations
            # convert=False prevents automatic type inference/conversion
            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 = ...,

Review comment (suggestion):
This and the comments below do not add anything that isn't already in the code. Can you remove them.

Code after:

        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,
        q: float | Sequence[float] | AnyArrayLike = ...,