-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
BUG: Index.getitem returning wrong result with negative step for arrow #55832
Conversation
pandas/core/arrays/arrow/array.py
Outdated
if isinstance(item, slice): | ||
if item.start == item.stop: | ||
pass | ||
elif item.start == -len(self) - 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be item.start < -len(self)
?
Not sure if you want to mimic numpy behavior here but numpy allows slicing beyond the len of the array:
In [1]: import numpy as np
In [2]: np.array(["a", "b", "c"])[slice(-10, 10)]
Out[2]: array(['a', 'b', 'c'], dtype='<U1')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes sense, updated
item.stop is not None | ||
and item.stop < -len(self) | ||
and item.step is not None | ||
and item.step < 0 | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment about why we do this (or refer to a pyarrow bug report or this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the arrow ref
Opened an issue on the Arrow side -> apache/arrow#38768 |
Thanks @phofl |
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove the If these instructions are inaccurate, feel free to suggest an improvement. |
pandas-dev#55832) * BUG: Index.getitem returning wrong result with negative step for arrow * Update * Update * Fix * Update array.py * Fix * Add gh ref * Update (cherry picked from commit 196e907)
…g result with negative step for arrow) (#56121)
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.This omits b for arrow dtypes and looks like a bug on the arrow side, cc @jorisvandenbossche