pyarrow.compute.select_k_unstable

pyarrow.compute.select_k_unstable(input, /, k, sort_keys, *, options=None, memory_pool=None)

Select the indices of the first k ordered elements from the input.

This function selects an array of indices of the first k ordered elements from the input array, record batch or table specified in the column keys (options.sort_keys). Output is not guaranteed to be stable. Null values are considered greater than any other value and are therefore ordered at the end. For floating-point types, NaNs are considered greater than any other non-null value, but smaller than null values.

Parameters:
inputArray-like or scalar-like

Argument to compute function.

kint

Number of leading values to select in sorted order (i.e. the largest values if sort order is “descending”, the smallest otherwise).

sort_keyssequence of (name, order) tuples

Names of field/column keys to sort the input on, along with the order each field/column is sorted in. Accepted values for order are “ascending”, “descending”. The field name can be a string column name or expression.

optionspyarrow.compute.SelectKOptions, optional

Alternative way of passing options.

memory_poolpyarrow.MemoryPool, optional

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