edponce commented on a change in pull request #11164:
URL: https://github.com/apache/arrow/pull/11164#discussion_r709698208



##########
File path: python/pyarrow/compute.py
##########
@@ -643,3 +643,85 @@ def fill_null(values, fill_value):
         fill_value = pa.scalar(fill_value.as_py(), type=values.type)
 
     return call_function("coalesce", [values, fill_value])
+
+
+def top_k_unstable(values, k, sort_keys=[], memory_pool=None):
+    """
+    Select the indices of the top-k ordered elements from array- or table-like
+    data.
+
+    This is a specalizacion for :func:`select_k_unstable`. Output is not
+    guaranteed to be stable.
+
+    Parameters
+    ----------
+    values : Array, ChunkedArray, RecordBatch, or Table
+    k :  The number of `k` elements to keep.
+    sort_keys : Column key names to order by when input table-like data.
+
+    Returns
+    -------
+    result : Array of indices
+
+    Examples
+    --------
+    >>> import pyarrow as pa
+    >>> import pyarrow.compute as pc
+    >>> arr = pa.array(["a", "b", "c", None, "e", "f"])
+    >>> pc.top_k_unstable(arr, k=3)
+    <pyarrow.lib.UInt64Array object at 0x7fdcb19d7f30>
+    [
+      5,
+      4,
+      2
+    ]
+    """
+    sort_keys_opts = []
+    if isinstance(values, (pa.Array, pa.ChunkedArray)):
+        sort_keys_opts.append(("dummy", "descending"))
+    else:
+        for key_name in sort_keys:
+            sort_keys_opts.append((key_name, "descending"))
+    options = SelectKOptions(k=k, sort_keys=sort_keys_opts)
+    return call_function("select_k_unstable", [values], options, memory_pool)
+
+
+def bottom_k_unstable(values, k, sort_keys=[], memory_pool=None):
+    """
+    Select the indices of the bottom-k ordered elements from
+    array- or table-like data.
+
+    This is a specalizacion for :func:`select_k_unstable`. Output is not
+    guaranteed to be stable.

Review comment:
       Same spelling error as above.

##########
File path: python/pyarrow/compute.py
##########
@@ -643,3 +643,85 @@ def fill_null(values, fill_value):
         fill_value = pa.scalar(fill_value.as_py(), type=values.type)
 
     return call_function("coalesce", [values, fill_value])
+
+
+def top_k_unstable(values, k, sort_keys=[], memory_pool=None):
+    """
+    Select the indices of the top-k ordered elements from array- or table-like
+    data.
+
+    This is a specalizacion for :func:`select_k_unstable`. Output is not
+    guaranteed to be stable.

Review comment:
       Fix spelling _specialization_.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to