Skip to content

Commit 787d045

Browse files
phoflnoatamir
authored andcommitted
TYP: Specify how in dropna (pandas-dev#48289)
1 parent 75bcf24 commit 787d045

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

pandas/core/frame.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6423,7 +6423,7 @@ def dropna(
64236423
self,
64246424
*,
64256425
axis: Axis = ...,
6426-
how: str | NoDefault = ...,
6426+
how: Literal["any", "all"] | NoDefault = ...,
64276427
thresh: int | NoDefault = ...,
64286428
subset: IndexLabel = ...,
64296429
inplace: Literal[False] = ...,
@@ -6435,7 +6435,7 @@ def dropna(
64356435
self,
64366436
*,
64376437
axis: Axis = ...,
6438-
how: str | NoDefault = ...,
6438+
how: Literal["any", "all"] | NoDefault = ...,
64396439
thresh: int | NoDefault = ...,
64406440
subset: IndexLabel = ...,
64416441
inplace: Literal[True],
@@ -6446,7 +6446,7 @@ def dropna(
64466446
def dropna(
64476447
self,
64486448
axis: Axis = 0,
6449-
how: str | NoDefault = no_default,
6449+
how: Literal["any", "all"] | NoDefault = no_default,
64506450
thresh: int | NoDefault = no_default,
64516451
subset: IndexLabel = None,
64526452
inplace: bool = False,

pandas/core/indexes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2971,7 +2971,7 @@ def fillna(self, value=None, downcast=None):
29712971
)
29722972
return self._view()
29732973

2974-
def dropna(self: _IndexT, how: str_t = "any") -> _IndexT:
2974+
def dropna(self: _IndexT, how: Literal["any", "all"] = "any") -> _IndexT:
29752975
"""
29762976
Return Index without NA/NaN values.
29772977

pandas/core/indexes/multi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ def fillna(self, value=None, downcast=None):
16341634
raise NotImplementedError("isna is not defined for MultiIndex")
16351635

16361636
@doc(Index.dropna)
1637-
def dropna(self, how: str = "any") -> MultiIndex:
1637+
def dropna(self, how: Literal["any", "all"] = "any") -> MultiIndex:
16381638
nans = [level_codes == -1 for level_codes in self.codes]
16391639
if how == "any":
16401640
indexer = np.any(nans, axis=0)

pandas/core/series.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -5731,19 +5731,30 @@ def notnull(self) -> Series:
57315731

57325732
@overload
57335733
def dropna(
5734-
self, *, axis: Axis = ..., inplace: Literal[False] = ..., how: str | None = ...
5734+
self,
5735+
*,
5736+
axis: Axis = ...,
5737+
inplace: Literal[False] = ...,
5738+
how: Literal["any", "all"] | None = ...,
57355739
) -> Series:
57365740
...
57375741

57385742
@overload
57395743
def dropna(
5740-
self, *, axis: Axis = ..., inplace: Literal[True], how: str | None = ...
5744+
self,
5745+
*,
5746+
axis: Axis = ...,
5747+
inplace: Literal[True],
5748+
how: Literal["any", "all"] | None = ...,
57415749
) -> None:
57425750
...
57435751

57445752
@deprecate_nonkeyword_arguments(version=None, allowed_args=["self"])
57455753
def dropna(
5746-
self, axis: Axis = 0, inplace: bool = False, how: str | None = None
5754+
self,
5755+
axis: Axis = 0,
5756+
inplace: bool = False,
5757+
how: Literal["any", "all"] | None = None,
57475758
) -> Series | None:
57485759
"""
57495760
Return a new Series with missing values removed.

0 commit comments

Comments
 (0)