pyarrow.compute.bottom_k_unstable#
- pyarrow.compute.bottom_k_unstable(values, k, sort_keys=None, *, memory_pool=None)[source]#
Select the indices of the bottom-k ordered elements from array- or table-like data.
This is a specialization for
select_k_unstable(). Output is not guaranteed to be stable.- Parameters:
- values
Array,ChunkedArray,RecordBatch, orTable Data to sort and get bottom indices from.
- k
int The number of k elements to keep.
- sort_keysList-like
Column key names to order by when input is table-like data.
- memory_pool
MemoryPool, optional If not passed, will allocate memory from the default memory pool.
- values
- Returns:
- result
Arrayofindices Indices of the bottom-k ordered elements
- result
Examples
>>> import pyarrow as pa >>> import pyarrow.compute as pc >>> arr = pa.array(["a", "b", "c", None, "e", "f"]) >>> pc.bottom_k_unstable(arr, k=3) <pyarrow.lib.UInt64Array object at ...> [ 0, 1, 2 ]