DOC: improve the shared docstring of Series.str.strip() #20897
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
git diff upstream/master -u -- "*.py" | flake8 --diff
Docstring written with @jalammar as part of the pandas sprint at PyData London 2018, guided by @datapythonista. Wasn't too sure of the "Return" definition, so we defaulted to the one written for str_strip. Docstring is shared by the strip, lstrip, and rstrip methods, and validate_docstrings.py script output for the "script" variant is included below:
################################################################################
##################### Docstring (pandas.Series.str.strip) #####################
################################################################################
Strip combinations of characters from the left and right sides of strings.
Operates on each element in the given String/Index, and is equivalent to
:meth:
str.strip
.Parameters
to_strip : str or unicode, optional
String or unicode specifying the set of characters to be removed from
the left and right sides. If omitted or None, the strip method defaults to removing
whitespace and newlines.
Returns
stripped : Series/Index of objects
See Also
Series.str.strip : Removes defined characters from both sides
Series.str.lstrip : Removes defined characters from the left side
Series.str.rstrip : Removes defined characters from the right side
Examples
Rather than string matching, all combinations of the
to_strip
parameter'scharacters are removed.
################################################################################
################################## Validation ##################################
################################################################################
Docstring for "pandas.Series.str.strip" correct. :)