Skip to content

Conversation

MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Oct 22, 2025

This PR: adds annotations for:

  • adds annotations for DatetimeIndex.indexer_at_time
  • adds annotations for DatetimeIndex.indexer_between_time
  • adds annotations for DatetimeIndex.snap
  • removes DatetimeIndex.slice_indexer, as it can just inherit from Index.slice_indexer (there's no datetime-index-specific docs for this method)
  • removes DatetimeIndex.__reduce__ (not documented)
  • moves existing DatetimeIndex tests from tests/indexes/test_indexes.py to a new tests/indexes/test_datetime_index.py file
  • adds new tests for DatetimeIndex.indexer_at_time and DatetimeIndex.indexer_between_time to the test_datetime_index file

@MarcoGorelli MarcoGorelli marked this pull request as ready for review October 22, 2025 11:05
@MarcoGorelli MarcoGorelli force-pushed the datetimeindex-undocumented branch from 7312277 to d40f7e9 Compare October 22, 2025 11:06
Comment on lines 31 to 39
dt_idx = pd.DatetimeIndex(data, name="date")
check(assert_type(data[x <= dt_idx], pd.DatetimeIndex), pd.DatetimeIndex)
check(assert_type(data[x >= dt_idx], pd.DatetimeIndex), pd.DatetimeIndex)
check(assert_type(data[x < dt_idx], pd.DatetimeIndex), pd.DatetimeIndex)
check(assert_type(data[x > dt_idx], pd.DatetimeIndex), pd.DatetimeIndex)
check(assert_type(data[dt_idx <= x], pd.DatetimeIndex), pd.DatetimeIndex)
check(assert_type(data[dt_idx >= x], pd.DatetimeIndex), pd.DatetimeIndex)
check(assert_type(data[dt_idx < x], pd.DatetimeIndex), pd.DatetimeIndex)
check(assert_type(data[dt_idx > x], pd.DatetimeIndex), pd.DatetimeIndex)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems redundant, if my comment above is valid.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add # TODO: pandas-dev/pandas-stubs#1440 deduplicate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants