Skip to content

DOC: update the Index.sort_values docstring #20299

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

DataOmbudsman
Copy link
Contributor

Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):

  • PR title is "DOC: update the docstring"
  • The validation script passes: scripts/validate_docstrings.py <your-function-or-method>
  • The PEP8 style check passes: git diff upstream/master -u -- "*.py" | flake8 --diff
  • The html version looks good: python doc/make.py --single <your-function-or-method>
  • It has been proofread on language by another sprint participant

Please include the output of the validation script below between the "```" ticks:

################################################################################
##################### Docstring (pandas.Index.sort_values) #####################
################################################################################

Return a sorted copy of the index.

Return a sorted copy of the index, and optionally return the indices
that sorted the index itself.

Parameters
----------
return_indexer : bool, default False
    Should the indices that would sort the index be returned.
ascending : bool, default True
    Should the index values be sorted in an ascending order.

Returns
-------
sorted_index : pandas.Index
    Sorted copy of the index.
_as : numpy.ndarray, optional
    The indices that the index itself was sorted by.

See Also
--------
pandas.Series.sort_values : Sort values of a Series.
pandas.DataFrame.sort_values : Sort values in a DataFrame.

Examples
--------
>>> idx = pd.Index([10, 100, 1, 1000])
>>> idx
Int64Index([10, 100, 1, 1000], dtype='int64')

Sort values in ascending order (default behavior).

>>> idx.sort_values()
Int64Index([1, 10, 100, 1000], dtype='int64')

Sort values in descending order, and also get the indices `idx` was
sorted by.

>>> idx.sort_values(ascending=False, return_indexer=True)
(Int64Index([1000, 100, 10, 1], dtype='int64'), array([3, 1, 0, 2]))

################################################################################
################################## Validation ##################################
################################################################################

Docstring for "pandas.Index.sort_values" correct. :)

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.

@TomAugspurger TomAugspurger added Docs Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff labels Mar 12, 2018
Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change, LGTM otherwise.

-------
sorted_index : pandas.Index
Sorted copy of the index.
_as : numpy.ndarray, optional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think numpy usually calls this kind of array an indexer or index_array.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that's better

@codecov
Copy link

codecov bot commented Mar 12, 2018

Codecov Report

Merging #20299 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #20299   +/-   ##
=======================================
  Coverage   91.73%   91.73%           
=======================================
  Files         150      150           
  Lines       49168    49168           
=======================================
  Hits        45102    45102           
  Misses       4066     4066
Flag Coverage Δ
#multiple 90.11% <ø> (ø) ⬆️
#single 41.86% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/indexes/base.py 96.66% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0815c43...2d0f820. Read the comment docs.

@TomAugspurger
Copy link
Contributor

💯 Thanks @DataOmbudsman!

@TomAugspurger TomAugspurger merged commit 3392360 into pandas-dev:master Mar 12, 2018
@DataOmbudsman DataOmbudsman deleted the update_docstring_index_sort_values branch March 12, 2018 20:24
@jorisvandenbossche jorisvandenbossche added this to the 0.23.0 milestone Mar 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants