BUG: Index.getitem returning wrong result with negative step for arrow#55832
BUG: Index.getitem returning wrong result with negative step for arrow#55832mroeschke merged 13 commits intopandas-dev:mainfrom
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.
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.
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.
Can you add a comment about why we do this (or refer to a pyarrow bug report or this PR)
|
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.rstfile 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