nums.numpy.top_k

nums.numpy.top_k(a, k, largest=True, sorted=False)[source]

Find the k largest or smallest elements of a BlockArray.

If there are multiple kth elements that are equal in value, then no guarantees are made as to which ones are included in the top k.

Parameters
  • a (BlockArray) – A BlockArray.

  • k (int) – Number of top elements to return.

  • largest – Whether to return largest or smallest elements.

Return type

Tuple[BlockArray, BlockArray]

Returns

A tuple containing two BlockArrays, (values, indices). values: Values of the top k elements, unsorted. indices: Indices of the top k elements, ordered by their corresponding values.