-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
DOC: update the pd.Index.argsort docstring #20232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2316,16 +2316,36 @@ def shift(self, periods=1, freq=None): | |
|
||
def argsort(self, *args, **kwargs): | ||
""" | ||
Returns the indices that would sort the index and its | ||
underlying data. | ||
Return the order of the indices that would sort the index. | ||
|
||
Parameters | ||
---------- | ||
*args | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jorisvandenbossche this is the correct format for args/kwargs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I was only thinking it might actually make more sense to list the ones that are useful. I think it is only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes we do this for Series.argsort now. so should replicate here. or shared these doc-strings (best) |
||
Passed to `numpy.ndarray.argsort`. | ||
**kwargs | ||
Passed to `numpy.ndarray.argsort`. | ||
|
||
Returns | ||
------- | ||
argsorted : numpy array | ||
numpy.ndarray | ||
Argsorted indices of the index | ||
|
||
See also | ||
-------- | ||
numpy.ndarray.argsort | ||
numpy.ndarray.argsort : Similar method for NumPy arrays. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see also Index.sort_values |
||
pd.Index.sort_values : Return sorted copy of Index | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't need the pd. |
||
|
||
Examples | ||
-------- | ||
>>> pd.Index(['b','a','d','c']).argsort() | ||
array([1, 0, 3, 2], dtype=int64) | ||
|
||
When applying argsort to a Series object then the result won't | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think from here down is relevant. Series has its own example. |
||
be affected by Series values only by Series index. | ||
|
||
>>> s = pd.Series(data=[4, 3, 2, 1], index=['c', 'b', 'a', 'd']) | ||
>>> s.index.argsort() | ||
array([2, 1, 0, 3], dtype=int64) | ||
""" | ||
result = self.asi8 | ||
if result is None: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #20232 (comment)