Skip to content

TYPE: Move any all to _typing #48300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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