diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 045776c3f5c50..37fc5de95b3d2 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -5007,6 +5007,121 @@ def rename( errors=errors, ) + @overload + def fillna( + self, + value=..., + method: str | None = ..., + axis: Axis | None = ..., + inplace: Literal[False] = ..., + limit=..., + downcast=..., + ) -> DataFrame: + ... + + @overload + def fillna( + self, + value, + method: str | None, + axis: Axis | None, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + *, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + value, + *, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + *, + method: str | None, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + *, + axis: Axis | None, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + *, + method: str | None, + axis: Axis | None, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + value, + *, + axis: Axis | None, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + value, + method: str | None, + *, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + value=..., + method: str | None = ..., + axis: Axis | None = ..., + inplace: bool = ..., + limit=..., + downcast=..., + ) -> DataFrame | None: + ... + @doc(NDFrame.fillna, **_shared_doc_kwargs) def fillna( self, diff --git a/pandas/core/series.py b/pandas/core/series.py index 4b36b846ef9c4..5c605a6b441c6 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4581,6 +4581,121 @@ def drop( errors=errors, ) + @overload + def fillna( + self, + value=..., + method: str | None = ..., + axis: Axis | None = ..., + inplace: Literal[False] = ..., + limit=..., + downcast=..., + ) -> Series: + ... + + @overload + def fillna( + self, + value, + method: str | None, + axis: Axis | None, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + *, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + value, + *, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + *, + method: str | None, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + *, + axis: Axis | None, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + *, + method: str | None, + axis: Axis | None, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + value, + *, + axis: Axis | None, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + value, + method: str | None, + *, + inplace: Literal[True], + limit=..., + downcast=..., + ) -> None: + ... + + @overload + def fillna( + self, + value=..., + method: str | None = ..., + axis: Axis | None = ..., + inplace: bool = ..., + limit=..., + downcast=..., + ) -> Series | None: + ... + @doc(NDFrame.fillna, **_shared_doc_kwargs) def fillna( self, diff --git a/pandas/core/strings/object_array.py b/pandas/core/strings/object_array.py index f2027f2707a8b..dc4550484fa3b 100644 --- a/pandas/core/strings/object_array.py +++ b/pandas/core/strings/object_array.py @@ -5,7 +5,6 @@ Pattern, Set, Union, - cast, ) import unicodedata import warnings @@ -371,9 +370,7 @@ def _str_get_dummies(self, sep="|"): try: arr = sep + arr + sep except TypeError: - arr = cast(Series, arr) arr = sep + arr.astype(str) + sep - arr = cast(Series, arr) tags: Set[str] = set() for ts in Series(arr).str.split(sep):