Index.argsort()
Pandas Index.argsort()
returns integer indexes which will sort the index ... By default, the sort order was set in ascending order.
Syntax: Index.argsort (* args, ** kwargs)
Parameters:
* args: Passed to numpy.ndarray.argsort
** kwargs: Passed to numpy.ndarray.argsortReturns: numpy.ndarray
Integer indices that would sort the index if used as an indexer
Example # 1: Use Index.argsort ()
to find the order of indexes that will sort a given index.
|
Output:
Let’s find the order of the indexes that will sort the index.
|
Output:
As we can see in the output, the function returned the index order that would sort the given index. We can verify this by printing the Order Based Index.
|
Output:
As we can see in the output, it is printed in sorted order.
Example # 2: Use Index.argsort ()
to find the order of the indexes that will sort the given index.
|
Output:
Let’s find the order of the indexes that will sort the index.
|
Output:
As we can see in the output, the function returned the index order, which would sort the given index. We can verify this by printing the Order Based Index.
|
Output:
As we can see in the output, it is printed in sorted order.