8000 DOC: Fix Series nsmallest and nlargest docstring/doctests by Moisan · Pull Request #22731 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

DOC: Fix Series nsmallest and nlargest docstring/doctests #22731

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

Merged
merged 5 commits into from
Sep 18, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update nlargest and nsmallest docstring with backticks
  • Loading branch information
Thierry Moisan committed Sep 18, 2018
commit 5d6d5ed08a6ec75169ecd5df8dba360a6fe41264
31 changes: 15 additions & 16 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2756,7 +2756,7 @@ def nlargest(self, n=5, keep='first'):
Returns
-------
Series
The n largest values in the Series, sorted in decreasing order.
The `n` largest values in the Series, sorted in decreasing order.

Notes
-----
Expand Down Expand Up @@ -2788,7 +2788,7 @@ def nlargest(self, n=5, keep='first'):
Monserat 5200
dtype: int64

The n largest elements where n=5 by default.
The `n` largest elements where ``n=5`` by default.

>>> s.nlargest()
France 65000000
Expand All @@ -2798,17 +2798,16 @@ def nlargest(self, n=5, keep='first'):
Brunei 434000
dtype: int64

The n largest elements where n=3. Default keep value is 'first' so
Malta will
be kept.
The `n` largest elements where ``n=3``. Default `keep` value is 'first'
so Malta will be kept.

>>> s.nlargest(3)
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be nice to have just a quick one-liner to highlight the difference between this and the subsequent example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean a comment at the end of the line?

Copy link
Member

Choose a reason for hiding this comment

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

No just some text in between the examples to call out what the user should be looking at

France 65000000
Italy 59000000
Malta 434000
dtype: int64

The n largest elements where n=3 and keeping the last duplicates.
The `n` largest elements where ``n=3`` and keeping the last duplicates.
Brunei will be kept since it is the last with value 434000 based on
the index order.

Expand All @@ -2818,8 +2817,8 @@ def nlargest(self, n=5, keep='first'):
Brunei 434000
dtype: int64

The n largest elements where n=3 with all duplicates kept. Note that the
returned Series has five elements due to the three duplicates.
The `n` largest elements where ``n=3`` with all duplicates kept. Note
that the returned Series has five elements due to the three duplicates.

>>> s.nlargest(3, keep='all')
France 65000000
Expand Down Expand Up @@ -2850,7 +2849,7 @@ def nsmallest(self, n=5, keep='first'):
Returns
-------
Series
The n smallest values in the Series, sorted in increasing order.
The `n` smallest values in the Series, sorted in increasing order.

Notes
-----
Expand Down Expand Up @@ -2882,7 +2881,7 @@ def nsmallest(self, n=5, keep='first'):
Monserat 5200
dtype: int64

The n largest elements where n=5 by default.
The `n` largest elements where ``n=5`` by default.

>>> s.nsmallest()
Monserat 5200
Expand All @@ -2892,26 +2891,26 @@ def nsmallest(self, n=5, keep='first'):
Iceland 337000
dtype: int64

The n smallest elements where n=3. Default keep value is 'first' so
Nauru and Tuvalu will be kept.
The `n` smallest elements where ``n=3``. Default `keep` value is
'first' so Nauru and Tuvalu will be kept.

>>> s.nsmallest(3)
Monserat 5200
Nauru 11300
Tuvalu 11300
dtype: int64

The n smallest elements where n=3 and keeping the last duplicates.
Anguilla and Tuvalu will be kept since they are the last with value
11300 based on the index order.
The `n` smallest elements where ``n=3`` and keeping the last
duplicates. Anguilla and Tuvalu will be kept since they are the last
with value 11300 based on the index order.

>>> s.nsmallest(3, keep='last')
Monserat 5200
Anguilla 11300
Tuvalu 11300
dtype: int64

The n smallest elements where n=3 with all duplicates kept. Note
The `n` smallest elements where ``n=3`` with all duplicates kept. Note
that the returned Series has four elements due to the three duplicates.

>>> s.nsmallest(3, keep='all')
Expand Down
0