Skip to content

Commit 5a183d8

Browse files
committed
DOC: update the pd.Index.argsort docstring
1 parent c3d491a commit 5a183d8

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

pandas/core/indexes/base.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,16 +2316,36 @@ def shift(self, periods=1, freq=None):
23162316

23172317
def argsort(self, *args, **kwargs):
23182318
"""
2319-
Returns the indices that would sort the index and its
2320-
underlying data.
2319+
Return the order of the indices that would sort the index.
2320+
2321+
Parameters
2322+
----------
2323+
*args
2324+
Passed to `numpy.ndarray.argsort`.
2325+
**kwargs
2326+
Passed to `numpy.ndarray.argsort`.
23212327
23222328
Returns
23232329
-------
2324-
argsorted : numpy array
2330+
numpy.ndarray
2331+
Argsorted indices of the index
23252332
23262333
See also
23272334
--------
2328-
numpy.ndarray.argsort
2335+
numpy.ndarray.argsort : Similar method for NumPy arrays.
2336+
pd.Index.sort_values : Return sorted copy of Index
2337+
2338+
Examples
2339+
--------
2340+
>>> pd.Index(['b','a','d','c']).argsort()
2341+
array([1, 0, 3, 2], dtype=int64)
2342+
2343+
When applying argsort to a Series object then the result won't
2344+
be affected by Series values only by Series index.
2345+
2346+
>>> s = pd.Series(data=[4, 3, 2, 1], index=['c', 'b', 'a', 'd'])
2347+
>>> s.index.argsort()
2348+
array([2, 1, 0, 3], dtype=int64)
23292349
"""
23302350
result = self.asi8
23312351
if result is None:

0 commit comments

Comments
 (0)