Skip to content

Commit 15717ba

Browse files
authored
gh-591: changed the return type of argmin and argmax (#609)
* changed the return type and added test * changed the return type
1 parent 0e1e4c2 commit 15717ba

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pandas-stubs/core/base.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ class IndexOpsMixin(OpsMixin):
5757
def min(self, axis=..., skipna: bool = ..., **kwargs): ...
5858
def argmax(
5959
self, axis: AxisIndex | None = ..., skipna: bool = ..., *args, **kwargs
60-
) -> np.ndarray: ...
60+
) -> np.int64: ...
6161
def argmin(
6262
self, axis: AxisIndex | None = ..., skipna: bool = ..., *args, **kwargs
63-
) -> np.ndarray: ...
63+
) -> np.int64: ...
6464
def tolist(self) -> list: ...
6565
def to_list(self) -> list: ...
6666
def __iter__(self): ...

tests/test_pandas.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,3 +1973,11 @@ def g(x: pd.Series) -> int:
19731973
),
19741974
pd.DataFrame,
19751975
)
1976+
1977+
1978+
def test_argmin_and_argmax_return() -> None:
1979+
df = pd.DataFrame({"a": [-1, 0, 1], "b": [1, 2, 3]})
1980+
i = df.a.abs().argmin()
1981+
i1 = df.a.abs().argmax()
1982+
check(assert_type(i, np.int64), np.int64)
1983+
check(assert_type(i1, np.int64), np.int64)

0 commit comments

Comments
 (0)