-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: update Series.sort_values docstring #20247
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
Conversation
DOC Series.sort_values docstring [Sao Paulo]
Hello @rafarui! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on March 12, 2018 at 14:59 Hours UTC |
Can you follow the guidelines please: paste the output of the validation script above (you can still edit your top post). And check PEP8 as well, as you have some errors there. |
pandas/core/series.py
Outdated
Parameters | ||
---------- | ||
axis : {0 or ‘index’}, default 0 | ||
Axis to direct sorting. |
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.
I would mention here that is can only be 0 for Series (accepted for compatibility with DataFrame.sort_values)
pandas/core/series.py
Outdated
inplace : bool, default False | ||
If True, perform operation in-place. | ||
kind : {‘quicksort’, ‘mergesort’ or ‘heapsort’}, default ‘quicksort’ | ||
Choice of sorting algorithm. See also ndarray.np.sort [1]_ for more information. `mergesort` is the only stable |
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.
you can use :func:`np.sort`
as a syntax to create this reference automatically (then you don't need the [1]_
pandas/core/series.py
Outdated
7 45.0 | ||
dtype: float64 | ||
|
||
Sort values ascending order |
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.
Can you add something like (default behaviour)
?
pandas/core/series.py
Outdated
|
||
Examples | ||
-------- | ||
>>> s = pd.Series([np.nan, 1, 232, 323, 1, 2, 3, 45]) |
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.
I would make this a bit shorter (try to aim at 5 elements)
pandas/core/series.py
Outdated
2 232.0 | ||
3 323.0 | ||
dtype: float64 | ||
""" |
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.
If you find time, it would be nice to have an example that includes strings as well so that users see that sorting can apply to anything.
pandas/core/series.py
Outdated
0 NaN | ||
dtype: float64 | ||
|
||
Sort values descending order |
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.
Quick grammar comment: Sort values in descending order
pandas/core/series.py
Outdated
7 45.0 | ||
dtype: float64 | ||
|
||
Sort values ascending order |
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.
Quick grammar comment: Sort values in ascending order
fix reviewed pull request
pandas/core/series.py
Outdated
Examples | ||
-------- | ||
>>> s = pd.Series([np.nan, 1, 232, 323, 1, 2, 3, 45]) | ||
>>> s = pd.Series([np.nan, 1, 3, 5, 10]) |
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.
maybe put the 5 and 10 out of order?
change example as suggested
pandas/core/series.py
Outdated
""" | ||
Sort by the Series values. | ||
|
||
Sort (or order) a Series in ascending or descending order by some |
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.
by the values.
pandas/core/series.py
Outdated
""" | ||
Sort by the Series values. | ||
|
||
Sort (or order) a Series in ascending or descending order by some |
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.
just say Sort
Fix short description
lgtm. @jorisvandenbossche |
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.
Looking good! Added a few more comments
pandas/core/series.py
Outdated
inplace : bool, default False | ||
If True, perform operation in-place. | ||
kind : {‘quicksort’, ‘mergesort’ or ‘heapsort’}, default ‘quicksort’ | ||
Choice of sorting algorithm. See also :func:`np.sort` for more |
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.
np.sort -> numpy.sort
pandas/core/series.py
Outdated
If True, perform operation in-place. | ||
kind : {‘quicksort’, ‘mergesort’ or ‘heapsort’}, default ‘quicksort’ | ||
Choice of sorting algorithm. See also :func:`np.sort` for more | ||
information. `mergesort` is the only stable algorithm. |
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.
identation is off by one space here
pandas/core/series.py
Outdated
Choice of sorting algorithm. See also :func:`np.sort` for more | ||
information. `mergesort` is the only stable algorithm. | ||
na_position : {'first' or 'last'}, default 'last' | ||
Argument `first` puts NaNs at the beginning, `last` puts NaNs at |
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.
For first and last, can you use normal single quotes (not backticks) like in the line above?
pandas/core/series.py
Outdated
If `True` sort values in ascending order, otherwise descending. | ||
inplace : bool, default False | ||
If True, perform operation in-place. | ||
kind : {‘quicksort’, ‘mergesort’ or ‘heapsort’}, default ‘quicksort’ |
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.
it seems you are using here not the 'normal' single quote, but king of curved smart quote. Can you change this? (see the quotes in the type description of the na_position keyword, that are the good ones)
@rafarui Thanks a lot! |
Co-authored-by: @marielen
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py <your-function-or-method>
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>
Please include the output of the validation script below between the "```" ticks:
If the validation script still gives errors, but you think there is a good reason
to deviate in this case (and there are certainly such cases), please state this
explicitly.