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

Code before:
        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 len(self) == 0:
            return self.copy()

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

        if self.dtype == "object":
            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: ...

Review comment (suggestion):
1. self.dtype != "object", you can use is_object_dtype
2. This will raise error for Non empty series with dtype str etc. which is working now
>>> pd.Series(["a", "b"], dtype='str').round()
0    a
1    b
dtype: str

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 = ...,