pandas.Series.argsort

Override ndarray.argsort. Argsorts the value, omitting NA/null values, and places the result in the same locations as the non-NA values.

param axis
int

Has no effect but is accepted for compatibility with numpy.

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

Choice of sorting algorithm. See np.sort for more information. ‘mergesort’ is the only stable algorithm

param order
None

Has no effect but is accepted for compatibility with numpy.

return

Series Positions of values within the sort order with -1 indicating nan values.

Limitations

  • Parameter axis is supported only with default value 0.

  • Parameter order is supported only with default value None.

  • Parameter kind is supported only with values 'mergesort' and 'quicksort'.

  • This function may reveal slower performance than Pandas* on user system. Users should exercise a tradeoff

    between staying in JIT-region with that function or going back to interpreter mode.

Examples

Override ndarray.argsort.
import numpy as np
import pandas as pd
from numba import njit


@njit
def series_argsort():
    s = pd.Series([3, -10, np.nan, 0, 92])

    return s.argsort()  # Expect series of 1, 2, -1, 0, 3


print(series_argsort())
$ python ./series/series_argsort.py
0    1
1    2
2   -1
3    0
4    3
dtype: int64

See also

numpy.ndarray.argsort

Return indices of the minimum values along the given axis.