Skip to content

Commit 1bf85c2

Browse files
committed
restore DateTimeIndex methods
1 parent 70ef608 commit 1bf85c2

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

pandas-stubs/core/indexes/datetimelike.pyi

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import numpy as np
12
from pandas.core.indexes.extension import ExtensionIndex
23
from pandas.core.indexes.timedeltas import TimedeltaIndex
34
from typing_extensions import Self
45

56
from pandas._libs.tslibs import BaseOffset
67
from pandas._typing import (
78
S1,
9+
AxisIndex,
810
TimeUnit,
911
)
1012

@@ -15,6 +17,18 @@ class DatetimeIndexOpsMixin(ExtensionIndex[S1]):
1517
def freqstr(self) -> str | None: ...
1618
@property
1719
def is_all_dates(self) -> bool: ...
20+
def min(
21+
self, axis: AxisIndex | None = ..., skipna: bool = ..., *args, **kwargs
22+
) -> S1: ...
23+
def argmin(
24+
self, axis: AxisIndex | None = ..., skipna: bool = ..., *args, **kwargs
25+
) -> np.int64: ...
26+
def max(
27+
self, axis: AxisIndex | None = ..., skipna: bool = ..., *args, **kwargs
28+
) -> S1: ...
29+
def argmax(
30+
self, axis: AxisIndex | None = ..., skipna: bool = ..., *args, **kwargs
31+
) -> np.int64: ...
1832
def __rsub__( # type: ignore[override]
1933
self, other: DatetimeIndexOpsMixin
2034
) -> TimedeltaIndex: ...

tests/test_indexes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,8 +1344,8 @@ def test_datetime_index_max_min_reductions() -> None:
13441344
dtidx = pd.DatetimeIndex(["2020-01-01", "2020-01-02"])
13451345
check(assert_type(dtidx.argmax(), np.int64), np.int64)
13461346
check(assert_type(dtidx.argmin(), np.int64), np.int64)
1347-
check(assert_type(dtidx.max(), Any), pd.Timestamp)
1348-
check(assert_type(dtidx.min(), Any), pd.Timestamp)
1347+
check(assert_type(dtidx.max(), pd.Timestamp), pd.Timestamp)
1348+
check(assert_type(dtidx.min(), pd.Timestamp), pd.Timestamp)
13491349

13501350

13511351
def test_periodindex_shift() -> None:

0 commit comments

Comments
 (0)