diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 6c0a747b16745..a8c33a144378e 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -5545,7 +5545,7 @@ def replace( inplace: bool = False, limit=None, regex: bool = False, - method: str | lib.NoDefault = lib.no_default, + method: Literal["pad", "ffill", "bfill"] | lib.NoDefault = lib.no_default, ): return super().replace( to_replace=to_replace, diff --git a/pandas/core/generic.py b/pandas/core/generic.py index a10cfe1c615fa..34db1ab813dd1 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -6608,7 +6608,7 @@ def replace( inplace: bool_t = False, limit: int | None = None, regex=False, - method=lib.no_default, + method: Literal["pad", "ffill", "bfill"] | lib.NoDefault = lib.no_default, ): if not ( is_scalar(to_replace) diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 15d06ef3bc8e5..4da39318579eb 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -2643,7 +2643,10 @@ def _get_indexer_level_0(self, target) -> npt.NDArray[np.intp]: return ci.get_indexer_for(target) def get_slice_bound( - self, label: Hashable | Sequence[Hashable], side: str, kind=lib.no_default + self, + label: Hashable | Sequence[Hashable], + side: Literal["left", "right"], + kind=lib.no_default, ) -> int: """ For an ordered MultiIndex, compute slice bound @@ -2758,7 +2761,7 @@ def slice_locs( # happens in get_slice_bound method), but it adds meaningful doc. return super().slice_locs(start, end, step) - def _partial_tup_index(self, tup: tuple, side="left"): + def _partial_tup_index(self, tup: tuple, side: Literal["left", "right"] = "left"): if len(tup) > self._lexsort_depth: raise UnsortedIndexError( f"Key length ({len(tup)}) was greater than MultiIndex lexsort depth " diff --git a/pandas/core/series.py b/pandas/core/series.py index 06815348fe4b9..cdebb67e1b6dc 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5204,7 +5204,7 @@ def replace( inplace=False, limit=None, regex=False, - method: str | lib.NoDefault = lib.no_default, + method: Literal["pad", "ffill", "bfill"] | lib.NoDefault = lib.no_default, ): return super().replace( to_replace=to_replace, diff --git a/pandas/core/shared_docs.py b/pandas/core/shared_docs.py index 3a8a95865d10e..09ee254633b22 100644 --- a/pandas/core/shared_docs.py +++ b/pandas/core/shared_docs.py @@ -541,7 +541,7 @@ string. Alternatively, this could be a regular expression or a list, dict, or array of regular expressions in which case `to_replace` must be ``None``. - method : {{'pad', 'ffill', 'bfill', `None`}} + method : {{'pad', 'ffill', 'bfill'}} The method to use when for replacement, when `to_replace` is a scalar, list or tuple and `value` is ``None``. diff --git a/pandas/core/window/expanding.py b/pandas/core/window/expanding.py index d1a8b70b34462..dcdcbc0483d59 100644 --- a/pandas/core/window/expanding.py +++ b/pandas/core/window/expanding.py @@ -9,6 +9,7 @@ from pandas._typing import ( Axis, + QuantileInterpolation, WindowingRankType, ) @@ -651,7 +652,7 @@ def kurt(self, numeric_only: bool = False, **kwargs): def quantile( self, quantile: float, - interpolation: str = "linear", + interpolation: QuantileInterpolation = "linear", numeric_only: bool = False, **kwargs, ): diff --git a/pandas/core/window/rolling.py b/pandas/core/window/rolling.py index b45f43adbe952..6e47c46cc7203 100644 --- a/pandas/core/window/rolling.py +++ b/pandas/core/window/rolling.py @@ -29,6 +29,7 @@ ArrayLike, Axis, NDFrameT, + QuantileInterpolation, WindowingRankType, ) from pandas.compat._optional import import_optional_dependency @@ -1658,7 +1659,7 @@ def kurt(self, numeric_only: bool = False, **kwargs): def quantile( self, quantile: float, - interpolation: str = "linear", + interpolation: QuantileInterpolation = "linear", numeric_only: bool = False, **kwargs, ): @@ -2553,7 +2554,7 @@ def kurt(self, numeric_only: bool = False, **kwargs): def quantile( self, quantile: float, - interpolation: str = "linear", + interpolation: QuantileInterpolation = "linear", numeric_only: bool = False, **kwargs, ):