-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
DOC: update the pandas.Series.str.strip docstring #20628
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2094,8 +2094,46 @@ def encode(self, encoding, errors="strict"): | |
return self._wrap_result(result) | ||
|
||
_shared_docs['str_strip'] = (""" | ||
Strip whitespace (including newlines) from each string in the | ||
Series/Index from %(side)s. Equivalent to :meth:`str.%(method)s`. | ||
Strip whitespaces from string in Series. | ||
|
||
Strip whitespace (including newlines) or given string from | ||
each string in the Series/Index from %(side)s. Equivalent to | ||
:meth:`str.%(method)s`. | ||
|
||
Parameters | ||
---------- | ||
to_strip : str or unicode | ||
String or unicode to strip in the given string. | ||
|
||
Examples | ||
-------- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
>>> # strip method | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can write sentences explaining what you're doing without making then Python comments. Check the docstring guide or other docstrings already improved. |
||
>>> s = pd.Series([' This is a Test 1 ']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd create a single Series with all the values you want to use in the examples, and then apply all operations to it. |
||
>>> s | ||
0 This is a Test 1 | ||
dtype: object | ||
>>> s = s.str.strip() | ||
>>> s | ||
0 This is a Test 1 | ||
dtype: object | ||
>>> # lstrip method | ||
>>> s1 = pd.Series(['This is another Test']) | ||
>>> s1 | ||
0 This is another Test | ||
dtype: object | ||
>>> s1 = s1.str.lstrip('This') | ||
>>> s1 | ||
0 is another Test | ||
dtype: object | ||
>>> # rstrip method | ||
>>> s2 = pd.Series(['This is the last test']) | ||
>>> s2 | ||
0 This is the last test | ||
dtype: object | ||
>>> s2 = s2.str.rstrip('test') | ||
>>> s2 | ||
0 This is the last | ||
dtype: object | ||
|
||
Returns | ||
------- | ||
|
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.
Not necessarily whitespaces.