Skip to content

DOC: Update the pandas.Series.str.count() docstring (Delhi) #20154

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 14, 2018

Conversation

Ridhwanluthra
Copy link

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.count)  #####################
################################################################################

Count occurrences of pattern in each string of the Series/Index.

This function is used to count the number of times a particular regex
pattern is repeated in each of the string elements of the
:class:`~pandas.Series`.

Parameters
----------
pat : str
    Valid regular expression.
flags : int, default 0, meaning no flags
    Flags for re module, e.g. re.IGNORECASE.

Returns
-------
counts : Series/Index of integer values

Notes
-----
Some characters need to be escaped when passing in pat.
eg. '$' has a special meaning in regex and must be escaped when finding
specifically this char.

Examples
--------
Take a look at
`this link <https://docs.python.org/3/howto/regex.html#compilation-flags>`_
for the list of all possible flags that can be used.

>>> s = pd.Series(['A', 'B', 'Aaba', 'Baca', np.nan, 'CABA', 'cat'])
>>> s.str.count('a')
0    0.0
1    0.0
2    2.0
3    2.0
4    NaN
5    0.0
6    1.0
dtype: float64

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

Errors found:
	Errors in parameters section
		Parameters {'kwargs'} not documented
	See Also section not found

As discussed in the gitter channel it was suggested to ignore kwargs for now.
Not sure what should be a part of see also here.


Examples
--------
Take a look at
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe move this link to be under the flags parameter?

Copy link
Author

Choose a reason for hiding this comment

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

I like that idea, will do

4 NaN
5 0.0
6 1.0
dtype: float64
Copy link
Contributor

Choose a reason for hiding this comment

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

Add an examle with special characters like $?

Copy link
Author

Choose a reason for hiding this comment

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

should I remove the note in the doc?

@jreback jreback added Docs Strings String extension data type and string data labels Mar 10, 2018
@codecov
Copy link

codecov bot commented Mar 14, 2018

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #20154      +/-   ##
==========================================
- Coverage   91.72%   91.72%   -0.01%     
==========================================
  Files         150      150              
  Lines       49156    49152       -4     
==========================================
- Hits        45090    45086       -4     
  Misses       4066     4066
Flag Coverage Δ
#multiple 90.11% <ø> (-0.01%) ⬇️
#single 41.84% <ø> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/strings.py 98.32% <ø> (ø) ⬆️
pandas/core/base.py 96.78% <0%> (-0.02%) ⬇️
pandas/core/series.py 93.85% <0%> (-0.01%) ⬇️
pandas/core/indexes/base.py 96.66% <0%> (-0.01%) ⬇️
pandas/core/indexes/multi.py 95.06% <0%> (ø) ⬆️
pandas/core/generic.py 95.84% <0%> (ø) ⬆️
pandas/plotting/_core.py 82.23% <0%> (ø) ⬆️

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 840d432...93d2257. Read the comment docs.

@Ridhwanluthra
Copy link
Author

@TomAugspurger please take a look at the update

[ci skip]
@TomAugspurger TomAugspurger added this to the 0.23.0 milestone Mar 14, 2018
@TomAugspurger
Copy link
Contributor

Thanks!

@TomAugspurger TomAugspurger merged commit e3f9633 into pandas-dev:master Mar 14, 2018
@Ridhwanluthra Ridhwanluthra deleted the doc_str_count branch March 19, 2018 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Strings String extension data type and string data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants