jorisvandenbossche opened a new issue, #38768:
URL: https://github.com/apache/arrow/issues/38768

   From https://github.com/pandas-dev/pandas/pull/55832
   
   When slicing an array "backwards" (with negative step, -1 in the example), 
and when the `stop` is "beyond" the start (larger negative number than number 
of elements), the first item is not included:
   
   ```
   In [9]: arr = pa.array([0, 1, 2, 3, 4])
   
   In [10]: arr[4:-6:-1]
   Out[10]: 
   <pyarrow.lib.Int64Array object at 0x7faab0eaf8e0>
   [
     4,
     3,
     2,
     1
   ]
   ```
   
   While if we omit the `stop` (meaning, slice until the end, in this case of 
backwards slicing until the start), it works correctly:
   
   ```
   In [11]: arr[4::-1]
   Out[11]: 
   <pyarrow.lib.Int64Array object at 0x7faab0eac340>
   [
     4,
     3,
     2,
     1,
     0
   ]
   ```
   
   I haven't yet checked if this is an issue in the underlying C++ slicing, or 
in the Python layer, eg in our "normalize_slice" logic:
   
   
https://github.com/apache/arrow/blob/26cf0e0b154b188499676466579e977829c346f6/python/pyarrow/array.pxi#L544
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to