Skip to content

Commit 0ed9916

Browse files
dajcsTomAugspurger
authored andcommitted
DOC: update the pd.Index.argsort docstring (#20232)
* DOC: update the pd.Index.argsort docstring * Updated * Clarify * Missing .
1 parent eea0350 commit 0ed9916

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

pandas/core/indexes/base.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,16 +2442,38 @@ def shift(self, periods=1, freq=None):
24422442

24432443
def argsort(self, *args, **kwargs):
24442444
"""
2445-
Returns the indices that would sort the index and its
2446-
underlying data.
2445+
Return the integer indicies that would sort the index.
2446+
2447+
Parameters
2448+
----------
2449+
*args
2450+
Passed to `numpy.ndarray.argsort`.
2451+
**kwargs
2452+
Passed to `numpy.ndarray.argsort`.
24472453
24482454
Returns
24492455
-------
2450-
argsorted : numpy array
2456+
numpy.ndarray
2457+
Integer indicies that would sort the index if used as
2458+
an indexer.
24512459
24522460
See also
24532461
--------
2454-
numpy.ndarray.argsort
2462+
numpy.argsort : Similar method for NumPy arrays.
2463+
Index.sort_values : Return sorted copy of Index.
2464+
2465+
Examples
2466+
--------
2467+
>>> idx = pd.Index(['b', 'a', 'd', 'c'])
2468+
>>> idx
2469+
Index(['b', 'a', 'd', 'c'], dtype='object')
2470+
2471+
>>> order = idx.argsort()
2472+
>>> order
2473+
array([1, 0, 3, 2])
2474+
2475+
>>> idx[order]
2476+
Index(['a', 'b', 'c', 'd'], dtype='object')
24552477
"""
24562478
result = self.asi8
24572479
if result is None:

0 commit comments

Comments
 (0)