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

   ### Describe the enhancement requested
   
   # Description:
   pc.list_element(array, index) only accepts scalar integer indices. This 
prevents efficient vectorized operations. For example, to get the last element 
from each list:
   
   ```python
   import pyarrow as pa
   import pyarrow.compute as pc
   arr = pa.array([[1, 2, 3], [4, 5], [6, 7, 8, 9]])
   ```
   # Desired but not supported:
   ```python
   indices = pa.array([2, 1, 3])  # or [-1, -1, -1]
   result = pc.list_element(arr, indices)  # Should return [3, 5, 9]
   ```
   # Use Case:
   pandas needs this for efficient .list[-1] operations with pyarrow-backed 
arrays. Currently, pandas must use slow Python loops as a workaround.
   
   # Proposed Solution:
   Extend pc.list_element to accept array indices (like other compute functions 
do). This would enable vectorized element access from lists.
   
   # Related Issues:
   
   pandas issue: (#63221)
   
   ### Component(s)
   
   Python


-- 
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