pyarrow.compute.take#

pyarrow.compute.take(data,indices,*,boundscheck=True,memory_pool=None)[source]#

Select values (or records) from array- or table-like data given integerselection indices.

The result will be of the same type(s) as the input, with elements takenfrom the input array (or record batch / table fields) at the givenindices. If an index is null then the corresponding value in the outputwill be null.

Parameters:
dataArray,ChunkedArray,RecordBatch, orTable
indicesArray,ChunkedArray

Must be of integer type

boundscheckbool, defaultTrue

Whether to boundscheck the indices. If False and there is an out ofbounds index, will likely cause the process to crash.

memory_poolMemoryPool, optional

If not passed, will allocate memory from the default memory pool.

Returns:
resultdepends on inputs

Selected values for the given indices

Examples

>>>importpyarrowaspa>>>arr=pa.array(["a","b","c",None,"e","f"])>>>indices=pa.array([0,None,4,3])>>>arr.take(indices)<pyarrow.lib.StringArray object at ...>[  "a",  null,  "e",  null]