MCPcopy Create free account
hub / github.com/apache/arrow / take

Function take

python/pyarrow/compute.py:468–509  ·  view source on GitHub ↗

Select values (or records) from array- or table-like data given integer selection indices. The result will be of the same type(s) as the input, with elements taken from the input array (or record batch / table fields) at the given indices. If an index is null then the correspon

(data, indices, *, boundscheck=True, memory_pool=None)

Source from the content-addressed store, hash-verified

466
467
468def take(data, indices, *, boundscheck=True, memory_pool=None):
469 """
470 Select values (or records) from array- or table-like data given integer
471 selection indices.
472
473 The result will be of the same type(s) as the input, with elements taken
474 from the input array (or record batch / table fields) at the given
475 indices. If an index is null then the corresponding value in the output
476 will be null.
477
478 Parameters
479 ----------
480 data : Array, ChunkedArray, RecordBatch, or Table
481 indices : Array, ChunkedArray
482 Must be of integer type
483 boundscheck : boolean, default True
484 Whether to boundscheck the indices. If False and there is an out of
485 bounds index, will likely cause the process to crash.
486 memory_pool : MemoryPool, optional
487 If not passed, will allocate memory from the default memory pool.
488
489 Returns
490 -------
491 result : depends on inputs
492 Selected values for the given indices
493
494 Examples
495 --------
496 >>> import pyarrow as pa
497 >>> arr = pa.array(["a", "b", "c", None, "e", "f"])
498 >>> indices = pa.array([0, None, 4, 3])
499 >>> arr.take(indices)
500 <pyarrow.lib.StringArray object at ...>
501 [
502 "a",
503 null,
504 "e",
505 null
506 ]
507 """
508 options = TakeOptions(boundscheck=boundscheck)
509 return call_function('take', [data, indices], options, memory_pool)
510
511
512def fill_null(values, fill_value):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected