Skip to content

Commit

Permalink
TYPE: Move any all to _typing (pandas-dev#48300)
Browse files Browse the repository at this point in the history
  • Loading branch information
phofl authored and noatamir committed Nov 9, 2022
1 parent 8e1a43c commit 52fdb48
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions pandas/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,6 @@ def closed(self) -> bool:

# plotting
PlottingOrientation = Literal["horizontal", "vertical"]

# dropna
AnyAll = Literal["any", "all"]
7 changes: 4 additions & 3 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
)
from pandas._typing import (
AggFuncType,
AnyAll,
AnyArrayLike,
ArrayLike,
Axes,
Expand Down Expand Up @@ -6423,7 +6424,7 @@ def dropna(
self,
*,
axis: Axis = ...,
how: Literal["any", "all"] | NoDefault = ...,
how: AnyAll | NoDefault = ...,
thresh: int | NoDefault = ...,
subset: IndexLabel = ...,
inplace: Literal[False] = ...,
Expand All @@ -6435,7 +6436,7 @@ def dropna(
self,
*,
axis: Axis = ...,
how: Literal["any", "all"] | NoDefault = ...,
how: AnyAll | NoDefault = ...,
thresh: int | NoDefault = ...,
subset: IndexLabel = ...,
inplace: Literal[True],
Expand All @@ -6446,7 +6447,7 @@ def dropna(
def dropna(
self,
axis: Axis = 0,
how: Literal["any", "all"] | NoDefault = no_default,
how: AnyAll | NoDefault = no_default,
thresh: int | NoDefault = no_default,
subset: IndexLabel = None,
inplace: bool = False,
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
tz_compare,
)
from pandas._typing import (
AnyAll,
ArrayLike,
Axes,
Dtype,
Expand Down Expand Up @@ -2971,7 +2972,7 @@ def fillna(self, value=None, downcast=None):
)
return self._view()

def dropna(self: _IndexT, how: Literal["any", "all"] = "any") -> _IndexT:
def dropna(self: _IndexT, how: AnyAll = "any") -> _IndexT:
"""
Return Index without NA/NaN values.
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
)
from pandas._libs.hashtable import duplicated
from pandas._typing import (
AnyAll,
AnyArrayLike,
DtypeObj,
F,
Expand Down Expand Up @@ -1634,7 +1635,7 @@ def fillna(self, value=None, downcast=None):
raise NotImplementedError("isna is not defined for MultiIndex")

@doc(Index.dropna)
def dropna(self, how: Literal["any", "all"] = "any") -> MultiIndex:
def dropna(self, how: AnyAll = "any") -> MultiIndex:
nans = [level_codes == -1 for level_codes in self.codes]
if how == "any":
indexer = np.any(nans, axis=0)
Expand Down
7 changes: 4 additions & 3 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from pandas._libs.lib import no_default
from pandas._typing import (
AggFuncType,
AnyAll,
AnyArrayLike,
ArrayLike,
Axis,
Expand Down Expand Up @@ -5735,7 +5736,7 @@ def dropna(
*,
axis: Axis = ...,
inplace: Literal[False] = ...,
how: Literal["any", "all"] | None = ...,
how: AnyAll | None = ...,
) -> Series:
...

Expand All @@ -5745,7 +5746,7 @@ def dropna(
*,
axis: Axis = ...,
inplace: Literal[True],
how: Literal["any", "all"] | None = ...,
how: AnyAll | None = ...,
) -> None:
...

Expand All @@ -5754,7 +5755,7 @@ def dropna(
self,
axis: Axis = 0,
inplace: bool = False,
how: Literal["any", "all"] | None = None,
how: AnyAll | None = None,
) -> Series | None:
"""
Return a new Series with missing values removed.
Expand Down

0 comments on commit 52fdb48

Please sign in to comment.