Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

pyarrow chunkedarray get items at given indices

Say I have

In [3]: import pyarrow as pa

In [4]: ca = pa.chunked_array([[1,2,3], [4,5,6]])

I’d like to extract elements [1, 4, 2] and end up with

<pyarrow.lib.Int64Array object at 0x7f6eb43c2d40>
[
  2,
  5,
  3
]

as if I was doing NumPy-style indexing

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use the take function

import pyarrow as pa
ca = pa.chunked_array([[1, 2, 3], [4, 5, 6]])
subset = ca.take([1, 2, 3])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading