Skip to content

DOC: Improving the docstring of Series.str.upper and related #20462

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 4 commits into from
Mar 28, 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
52 changes: 51 additions & 1 deletion pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2145,11 +2145,61 @@ def rindex(self, sub, start=0, end=None):

_shared_docs['casemethods'] = ("""
Convert strings in the Series/Index to %(type)s.

Equivalent to :meth:`str.%(method)s`.

Returns
-------
converted : Series/Index of objects
Series/Index of objects

See Also
--------
Series.str.lower : Converts all characters to lower case.
Copy link
Member

Choose a reason for hiding this comment

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

"lower case" -> "lowercase" ?
Or at least we should be consistent with what is substituted in the summary line (currently this is "lowercase")

Series.str.upper : Converts all characters to upper case.
Series.str.title : Converts first character of each word to upper case and
remaining to lower case.
Series.str.capitalize : Converts first character to upper case and
remaining to lower case.
Series.str.swapcase : Converts upper case to lower case and lower case to
upper case.

Examples
--------
>>> s = pd.Series(['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe'])
>>> s.str.lower()
Copy link
Member

Choose a reason for hiding this comment

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

Could you show the original s, (simply with a line >>> s and its output). And then leave a blank line between it and the lower method, so the lower doesn't get grouped with the constructor and the original, but in a separate block as the rest?

Besides that, lgtm.

0 lower
1 capitals
2 this is a sentence
3 swapcase
dtype: object

>>> s.str.upper()
0 LOWER
1 CAPITALS
2 THIS IS A SENTENCE
3 SWAPCASE
dtype: object

>>> s.str.title()
0 Lower
1 Capitals
2 This Is A Sentence
3 Swapcase
dtype: object

>>> s.str.capitalize()
0 Lower
1 Capitals
2 This is a sentence
3 Swapcase
dtype: object

>>> s.str.swapcase()
0 LOWER
1 capitals
2 THIS IS A SENTENCE
3 sWaPcAsE
dtype: object
""")
_shared_docs['lower'] = dict(type='lowercase', method='lower')
_shared_docs['upper'] = dict(type='uppercase', method='upper')
Expand Down