cudf.Series.argsort#

Series.argsort(axis=0, kind='quicksort', order=None, ascending=True, na_position='last') Self[source]#

Return the integer indices that would sort the Series values.

Parameters:
bystr or list of str, default None

Name or list of names to sort by. If None, sort by all columns.

axis{0 or “index”}

Has no effect but is accepted for compatibility with numpy.

kind{‘mergesort’, ‘quicksort’, ‘heapsort’, ‘stable’}, default ‘quicksort’

Choice of sorting algorithm. See numpy.sort() for more information. ‘mergesort’ and ‘stable’ are the only stable algorithms. Only quicksort is supported in cuDF.

orderNone

Has no effect but is accepted for compatibility with numpy.

ascendingbool or list of bool, default True

If True, sort values in ascending order, otherwise descending.

na_position{‘first’ or ‘last’}, default ‘last’

Argument ‘first’ puts NaNs at the beginning, ‘last’ puts NaNs at the end.

Returns:
cupy.ndarray: The indices sorted based on input.

Examples

Series

>>> import cudf
>>> s = cudf.Series([3, 1, 2])
>>> s
0    3
1    1
2    2
dtype: int64
>>> s.argsort()
0    1
1    2
2    0
dtype: int32
>>> s[s.argsort()]
1    1
2    2
0    3
dtype: int64

DataFrame >>> import cudf >>> df = cudf.DataFrame({‘foo’: [3, 1, 2]}) >>> df.argsort() array([1, 2, 0], dtype=int32)

Index >>> import cudf >>> idx = cudf.Index([3, 1, 2]) >>> idx.argsort() array([1, 2, 0], dtype=int32)