Skip to content

Conversation

suzyahyah
Copy link
Contributor

@suzyahyah suzyahyah commented Oct 7, 2025

Indexing with out of range datetime objects of higher resolution should return empty slice instead of raising KeyError.

This is to be "consistent with normal slicing, where out of range slice bounds return an empty object, and don't raise an error".

As per this issue 25803, specifically #25803 (comment), if the date is of higher resolution than the current object in the series, e.g., day>minutes, then the empty slice should be returned instead of KeyError.

@suzyahyah suzyahyah force-pushed the fix_datetime_indexing_emptyslice branch 4 times, most recently from 5cc24d3 to 628583d Compare October 7, 2025 05:22
@suzyahyah suzyahyah force-pushed the fix_datetime_indexing_emptyslice branch from 628583d to 35c218d Compare October 7, 2025 05:46
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.

Should DatetimeIndex indexing with strings ever raise KeyError?
1 participant