Skip to content
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

DOC" update the Pandas core window rolling count docstring" #20264

Conversation

tommy-stone
Copy link
Contributor

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

The rolling sum if it is a non-Nan value inside the window.

Returns
-------
Returns the object type with the sum of the window values
in the current row.

See Also
--------
Series.rolling : Calling object with Series data
DataFrame.rolling : Calling object with DataFrames

Examples
--------
>>> s = pd.Series([2, 3, np.nan, 'values'])
>>> s.rolling(2).count()
0    1.0
1    2.0
2    1.0
3    1.0
dtype: float64
>>> s.rolling(3).count()
0    1.0
1    2.0
2    2.0
3    2.0
dtype: float64
>>> s.rolling(4).count()
0    1.0
1    2.0
2    2.0
3    3.0
dtype: float64

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

Errors found:
	No extended summary found

If the validation script still gives errors, but you think there is a good reason
to deviate in this case (and there are certainly such cases), please state this
explicitly.

Checklist for other PRs (remove this part if you are doing a PR for the pandas documentation sprint):

  • closes #xxxx
  • tests added / passed
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

_shared_docs['count'] = """%(name)s count of number of non-NaN
observations inside provided window."""
_shared_docs['count'] = dedent(r"""
The %(name)s sum if it is a non-Nan value inside the window.
Copy link
Member

Choose a reason for hiding this comment

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

Using the word sum is confusing here for a count. Can you reword to the effect of "count of non-NaN observations..."?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"count of non-Nan observations inside the rolling window" would work?

Copy link
Member

Choose a reason for hiding this comment

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

Yes

Copy link
Member

Choose a reason for hiding this comment

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

@scriptomation be sure that you actually surround your reference to NaN in back ticks, so literally you would write non-`NaN` (capitalization matters too)

See Also
--------
Series.%(name)s : Calling object with Series data
DataFrame.%(name)s : Calling object with DataFrames
Copy link
Member

Choose a reason for hiding this comment

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

Can you link to Series / DataFrame sum methods?

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 take a look at how the other PRs did this, see eg https://github.com/pandas-dev/pandas/pull/19999/files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I will update that information.


Returns
-------
Returns the object type with the sum of the window values
Copy link
Member

Choose a reason for hiding this comment

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

Can you make note of what the return type is? Also similar comment as above - referring to sum within a count function is confusing. I'm not sure current row is the right concept here, though I understand what you are trying to get at

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 use a similar wording as here: https://github.com/pandas-dev/pandas/pull/20263/files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. How does this work?

Returns
-------
Series or Dataframe
Returned object type is determined by the caller of %(name)

Copy link
Member

Choose a reason for hiding this comment

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

I would just copy verbatim, so Returned object type is determined by the caller of the %(name)s calculation

See Also
--------
Series.%(name)s : Calling object with Series data
DataFrame.%(name)s : Calling object with DataFrames
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 take a look at how the other PRs did this, see eg https://github.com/pandas-dev/pandas/pull/19999/files


Examples
--------
>>> s = pd.Series([2, 3, np.nan, 'values'])
Copy link
Member

Choose a reason for hiding this comment

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

It's a bit strange to give an example with mixed floats / strings (I mean, in general that's not really good practice to have data like that). I think only using floats (with nans) is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to show an example of mixed values being counted, in case a mistake is made by having different types of data. I see what you are saying though since it's already stated in the description. I will update to only use floats and nans. Thanks!


Returns
-------
Returns the object type with the sum of the window values
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 use a similar wording as here: https://github.com/pandas-dev/pandas/pull/20263/files

@jorisvandenbossche
Copy link
Member

@scriptomation do you have time to update this based on the feedback?

@tommy-stone
Copy link
Contributor Author

@jorisvandenbossche Thank you for the feed back. Updating it this weekend and will resubmit.

@codecov
Copy link

codecov bot commented Mar 19, 2018

Codecov Report

Merging #20264 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #20264      +/-   ##
==========================================
- Coverage   91.77%   91.77%   -0.01%     
==========================================
  Files         152      152              
  Lines       49205    49204       -1     
==========================================
- Hits        45159    45158       -1     
  Misses       4046     4046
Flag Coverage Δ
#multiple 90.16% <100%> (-0.01%) ⬇️
#single 41.85% <41.66%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/window.py 96.26% <100%> (-0.01%) ⬇️
pandas/core/indexes/timedeltas.py 91.22% <0%> (ø) ⬆️
pandas/core/internals.py 95.53% <0%> (ø) ⬆️
pandas/core/indexes/base.py 96.68% <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 7273ea0...946836c. Read the comment docs.

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Thanks for the update!

(added a small fixup to also have this working with expanding)

@jorisvandenbossche jorisvandenbossche added this to the 0.23.0 milestone Mar 19, 2018
@jorisvandenbossche jorisvandenbossche merged commit bd8a3cf into pandas-dev:master Mar 19, 2018
@jorisvandenbossche
Copy link
Member

Thanks for the PR!

nehiljain added a commit to nehiljain/pandas that referenced this pull request Mar 21, 2018
…ame_describe

* upstream/master: (158 commits)
  Add link to "Craft Minimal Bug Report" blogpost (pandas-dev#20431)
  BUG: fixed json_normalize for subrecords with NoneTypes (pandas-dev#20030) (pandas-dev#20399)
  BUG: ExtensionArray.fillna for scalar values (pandas-dev#20412)
  DOC" update the Pandas core window rolling count docstring" (pandas-dev#20264)
  DOC: update the pandas.DataFrame.plot.hist docstring (pandas-dev#20155)
  DOC: Only use ~ in class links to hide prefixes. (pandas-dev#20402)
  Bug: Allow np.timedelta64 objects to index TimedeltaIndex (pandas-dev#20408)
  DOC: add disallowing of Series construction of len-1 list with index to whatsnew (pandas-dev#20392)
  MAINT: Remove weird pd file
  DOC: update the Index.isin docstring (pandas-dev#20249)
  BUG: Handle all-NA blocks in concat (pandas-dev#20382)
  DOC: update the pandas.core.resample.Resampler.fillna docstring (pandas-dev#20379)
  BUG: Don't raise exceptions splitting a blank string (pandas-dev#20067)
  DOC: update the pandas.DataFrame.cummax docstring (pandas-dev#20336)
  DOC: update the pandas.core.window.x.mean docstring (pandas-dev#20265)
  DOC: update the api.types.is_number docstring (pandas-dev#20196)
  Fix linter (pandas-dev#20389)
  DOC: Improved the docstring of pandas.Series.dt.to_pytimedelta (pandas-dev#20142)
  DOC: update the pandas.Series.dt.is_month_end docstring (pandas-dev#20181)
  DOC: update the window.Rolling.min docstring (pandas-dev#20263)
  ...
nikoskaragiannakis pushed a commit to nikoskaragiannakis/pandas that referenced this pull request Mar 25, 2018
dworvos pushed a commit to dworvos/pandas that referenced this pull request Apr 2, 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.

3 participants