Skip to content

Commit 7c42ae2

Browse files
ramvikramstwoertwein
authored andcommitted
gh:284 - resolving various axis types (pandas-dev#561)
* resolving various axis types * Removed commented lines and required changes done
1 parent fb9bf11 commit 7c42ae2

File tree

12 files changed

+313
-338
lines changed

12 files changed

+313
-338
lines changed

pandas-stubs/_typing.pyi

+3-8
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ class WriteExcelBuffer(WriteBuffer[bytes], Protocol):
198198

199199
FilePath: TypeAlias = str | PathLike[str]
200200

201-
AxisInt: TypeAlias = Literal[0, 1]
202-
Axis: TypeAlias = AxisInt | Literal["index", "columns", "rows"]
203201
IndexLabel: TypeAlias = Hashable | Sequence[Hashable]
204202
Label: TypeAlias = Hashable | None
205203
Level: TypeAlias = Hashable | int
@@ -229,12 +227,9 @@ AggFuncTypeFrame: TypeAlias = (
229227
)
230228

231229
num: TypeAlias = complex
232-
SeriesAxisType: TypeAlias = Literal[
233-
"index", 0
234-
] # Restricted subset of _AxisType for series
235-
AxisTypeIndex: TypeAlias = Literal["index", 0]
236-
AxisTypeColumn: TypeAlias = Literal["columns", 1]
237-
AxisType: TypeAlias = AxisTypeIndex | AxisTypeColumn
230+
AxisIndex: TypeAlias = Literal["index", 0]
231+
AxisColumn: TypeAlias = Literal["columns", 1]
232+
Axis: TypeAlias = AxisIndex | AxisColumn
238233
DtypeNp = TypeVar("DtypeNp", bound=np.dtype[np.generic])
239234
KeysArgType: TypeAlias = Any
240235
ListLike = TypeVar("ListLike", Sequence, np.ndarray, "Series", "Index")

pandas-stubs/core/algorithms.pyi

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from collections.abc import Sequence
2-
from typing import overload
2+
from typing import (
3+
Literal,
4+
overload,
5+
)
36

47
import numpy as np
58
from pandas import (
@@ -14,7 +17,6 @@ from pandas.api.extensions import ExtensionArray
1417

1518
from pandas._typing import (
1619
AnyArrayLike,
17-
AxisInt,
1820
IntervalT,
1921
TakeIndexer,
2022
)
@@ -74,7 +76,7 @@ def value_counts(
7476
def take(
7577
arr,
7678
indices: TakeIndexer,
77-
axis: AxisInt = 0,
79+
axis: Literal[0, 1] = 0,
7880
allow_fill: bool = False,
7981
fill_value=None,
8082
): ...

pandas-stubs/core/base.pyi

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ from pandas.core.arrays import ExtensionArray
1111
from pandas.core.arrays.categorical import Categorical
1212

1313
from pandas._typing import (
14+
AxisIndex,
1415
NaPosition,
1516
NDFrameT,
1617
Scalar,
17-
SeriesAxisType,
1818
npt,
1919
)
2020

@@ -56,10 +56,10 @@ class IndexOpsMixin(OpsMixin):
5656
def max(self, axis=..., skipna: bool = ..., **kwargs): ...
5757
def min(self, axis=..., skipna: bool = ..., **kwargs): ...
5858
def argmax(
59-
self, axis: SeriesAxisType | None = ..., skipna: bool = ..., *args, **kwargs
59+
self, axis: AxisIndex | None = ..., skipna: bool = ..., *args, **kwargs
6060
) -> np.ndarray: ...
6161
def argmin(
62-
self, axis: SeriesAxisType | None = ..., skipna: bool = ..., *args, **kwargs
62+
self, axis: AxisIndex | None = ..., skipna: bool = ..., *args, **kwargs
6363
) -> np.ndarray: ...
6464
def tolist(self) -> list: ...
6565
def to_list(self) -> list: ...

0 commit comments

Comments
 (0)