W3cubDocs

/pandas 0.25

pandas.Index.argsort

Index.argsort(self, *args, **kwargs) [source]

Return the integer indices that would sort the index.

Parameters:
*args

Passed to numpy.ndarray.argsort.

**kwargs

Passed to numpy.ndarray.argsort.

Returns:
numpy.ndarray

Integer indices that would sort the index if used as an indexer.

See also

numpy.argsort
Similar method for NumPy arrays.
Index.sort_values
Return sorted copy of Index.

Examples

>>> idx = pd.Index(['b', 'a', 'd', 'c'])
>>> idx
Index(['b', 'a', 'd', 'c'], dtype='object')
>>> order = idx.argsort()
>>> order
array([1, 0, 3, 2])
>>> idx[order]
Index(['a', 'b', 'c', 'd'], dtype='object')

© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.25.0/reference/api/pandas.Index.argsort.html