Skip to content

gh:284 - resolving various axis types #561

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 2 commits into from
Mar 2, 2023
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
11 changes: 3 additions & 8 deletions pandas-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ class WriteExcelBuffer(WriteBuffer[bytes], Protocol):

FilePath: TypeAlias = str | PathLike[str]

AxisInt: TypeAlias = Literal[0, 1]
Axis: TypeAlias = AxisInt | Literal["index", "columns", "rows"]
IndexLabel: TypeAlias = Hashable | Sequence[Hashable]
Label: TypeAlias = Hashable | None
Level: TypeAlias = Hashable | int
Expand Down Expand Up @@ -229,12 +227,9 @@ AggFuncTypeFrame: TypeAlias = (
)

num: TypeAlias = complex
SeriesAxisType: TypeAlias = Literal[
"index", 0
] # Restricted subset of _AxisType for series
AxisTypeIndex: TypeAlias = Literal["index", 0]
AxisTypeColumn: TypeAlias = Literal["columns", 1]
AxisType: TypeAlias = AxisTypeIndex | AxisTypeColumn
AxisIndex: TypeAlias = Literal["index", 0]
AxisColumn: TypeAlias = Literal["columns", 1]
Axis: TypeAlias = AxisIndex | AxisColumn
DtypeNp = TypeVar("DtypeNp", bound=np.dtype[np.generic])
KeysArgType: TypeAlias = Any
ListLike = TypeVar("ListLike", Sequence, np.ndarray, "Series", "Index")
Expand Down
8 changes: 5 additions & 3 deletions pandas-stubs/core/algorithms.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from collections.abc import Sequence
from typing import overload
from typing import (
Literal,
overload,
)

import numpy as np
from pandas import (
Expand All @@ -14,7 +17,6 @@ from pandas.api.extensions import ExtensionArray

from pandas._typing import (
AnyArrayLike,
AxisInt,
IntervalT,
TakeIndexer,
)
Expand Down Expand Up @@ -74,7 +76,7 @@ def value_counts(
def take(
arr,
indices: TakeIndexer,
axis: AxisInt = 0,
axis: Literal[0, 1] = 0,
allow_fill: bool = False,
fill_value=None,
): ...
6 changes: 3 additions & 3 deletions pandas-stubs/core/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ from pandas.core.arrays import ExtensionArray
from pandas.core.arrays.categorical import Categorical

from pandas._typing import (
AxisIndex,
NaPosition,
NDFrameT,
Scalar,
SeriesAxisType,
npt,
)

Expand Down Expand Up @@ -56,10 +56,10 @@ class IndexOpsMixin(OpsMixin):
def max(self, axis=..., skipna: bool = ..., **kwargs): ...
def min(self, axis=..., skipna: bool = ..., **kwargs): ...
def argmax(
self, axis: SeriesAxisType | None = ..., skipna: bool = ..., *args, **kwargs
self, axis: AxisIndex | None = ..., skipna: bool = ..., *args, **kwargs
) -> np.ndarray: ...
def argmin(
self, axis: SeriesAxisType | None = ..., skipna: bool = ..., *args, **kwargs
self, axis: AxisIndex | None = ..., skipna: bool = ..., *args, **kwargs
) -> np.ndarray: ...
def tolist(self) -> list: ...
def to_list(self) -> list: ...
Expand Down
Loading