Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in __getitem__ raising for slice DatetimeIndex #43428

Merged
merged 4 commits into from
Sep 9, 2021

Conversation

phofl
Copy link
Member

@phofl phofl commented Sep 6, 2021

@jbrockmendel Any idea why we used maybe_indices_to_slice instead of take like in loc?

@phofl phofl added Indexing Related to indexing on series/frames, not to indexes themselves Regression Functionality that used to work in a prior pandas version Datetime Datetime data dtype labels Sep 6, 2021
� Conflicts:
�	doc/source/whatsnew/v1.3.3.rst
@jbrockmendel
Copy link
Member

Any idea why we used maybe_indices_to_slice instead of take like in loc?

Best guess: if we have e.g. [0, 2, 4, 6] that we can change to slice(0, 8, 2), then a) the indexing is no-copy and b) we preserve e.g. DTI.freq and RangeIndex.

@phofl
Copy link
Member Author

phofl commented Sep 6, 2021

Hm good point, should we try to convert to slice and only if it fails, e.g. stays an ndarray, call take?

@jbrockmendel
Copy link
Member

Hm good point, should we try to convert to slice and only if it fails, e.g. stays an ndarray, call take?

i think thats what we're already doing isnt it?

@phofl
Copy link
Member Author

phofl commented Sep 6, 2021

I've removed the cast. Added it and we only call take if we can not convert to slice

@jreback jreback added this to the 1.3.3 milestone Sep 9, 2021
@phofl phofl merged commit a951998 into pandas-dev:master Sep 9, 2021
meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Sep 9, 2021
@phofl phofl deleted the 43223 branch September 9, 2021 13:51
jreback pushed a commit that referenced this pull request Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Indexing Related to indexing on series/frames, not to indexes themselves Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Slicing on Datetimeindex fails
3 participants