Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

techedlaksh
Copy link
Contributor

@techedlaksh techedlaksh commented Apr 7, 2018

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.Series.str.strip)  #####################
################################################################################

Strip whitespaces from string in Series.

Strip whitespace (including newlines) or given string from
each string in the Series/Index from left and right sides. Equivalent to
:meth:`str.strip`.

Parameters
----------
to_strip : str or unicode
    String or unicode to strip in the given string.

Examples
--------
>>> # strip method
>>> s = pd.Series(['   This is a Test 1  '])
>>> 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
-------
stripped : Series/Index of objects

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

Errors found:
	See Also section not found


@codecov
Copy link

codecov bot commented Apr 7, 2018

Codecov Report

Merging #20628 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #20628      +/-   ##
==========================================
+ Coverage   91.82%   91.82%   +<.01%     
==========================================
  Files         153      153              
  Lines       49256    49256              
==========================================
+ Hits        45227    45229       +2     
+ Misses       4029     4027       -2
Flag Coverage Δ
#multiple 90.21% <ø> (ø) ⬆️
#single 41.9% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/strings.py 98.32% <ø> (ø) ⬆️
pandas/util/testing.py 84.73% <0%> (+0.2%) ⬆️

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 6d610a4...f6cc70f. Read the comment docs.

String or unicode to strip in the given string.

Examples
--------
Copy link
Member

Choose a reason for hiding this comment

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

Examples section goes after Returns


Examples
--------
>>> # strip method
Copy link
Member

Choose a reason for hiding this comment

The 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.

Examples
--------
>>> # strip method
>>> s = pd.Series([' This is a Test 1 '])
Copy link
Member

Choose a reason for hiding this comment

The 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.

@@ -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.
Copy link
Member

Choose a reason for hiding this comment

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

Not necessarily whitespaces.

@gfyoung gfyoung added the Docs label Apr 10, 2018
@datapythonista
Copy link
Member

Seems like #20863 is also fixing the same docstring, and IMO looks better. I think we can close this one.

@mroeschke
Copy link
Member

Thanks @techedlaksh. Unfortunately it appears that there was some overlap with #20863; sorry about that. Feel free to work on other docstrings, always appreciated!

@mroeschke mroeschke closed this Jul 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants