Skip to content
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
14 changes: 13 additions & 1 deletion pandas-stubs/core/indexes/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
@overload
def __new__(
cls,
data: Sequence[np.datetime64 | datetime] | IndexOpsMixin[datetime],
data: (
Sequence[np.datetime64 | datetime] | IndexOpsMixin[datetime] | DatetimeIndex
),
*,
dtype: TimestampDtypeArg = ...,
copy: bool = ...,
Expand Down Expand Up @@ -274,6 +276,16 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
name: Hashable = ...,
tupleize_cols: bool = ...,
) -> IntervalIndex[Interval[Any]]: ...
@overload
def __new__(
cls,
data: DatetimeIndex,
*,
dtype: TimestampDtypeArg | None = ...,
copy: bool = ...,
name: Hashable = ...,
tupleize_cols: bool = ...,
) -> DatetimeIndex: ...
# generic overloads
@overload
def __new__(
Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/test_datetime_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_index_relops() -> None:
)
x = pd.Timestamp("2022-01-17")
idx = check(
assert_type(pd.Index(data, name="date"), "pd.Index[pd.Timestamp]"), pd.Index
assert_type(pd.Index(data, name="date"), pd.DatetimeIndex), pd.DatetimeIndex
)
check(assert_type(data[x <= idx], pd.DatetimeIndex), pd.DatetimeIndex)
check(assert_type(data[x < idx], pd.DatetimeIndex), pd.DatetimeIndex)
Expand Down