-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC" update the Pandas core window rolling count docstring" #20264
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 2 commits
6f59df9
4c1500c
a59c9cb
122f930
f8d77ef
946836c
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 |
---|---|---|
|
@@ -780,8 +780,41 @@ def calc(x): | |
|
||
class _Rolling_and_Expanding(_Rolling): | ||
|
||
_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. | ||
|
||
Returns | ||
------- | ||
Returns the object type with the sum of the window values | ||
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. Can you make note of what the return type is? Also similar comment as above - referring to 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 use a similar wording as here: https://github.com/pandas-dev/pandas/pull/20263/files 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. That makes sense. How does this work? Returns 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 would just copy verbatim, so |
||
in the current row. | ||
|
||
See Also | ||
-------- | ||
Series.%(name)s : Calling object with Series data | ||
DataFrame.%(name)s : Calling object with DataFrames | ||
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. Can you link to 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 take a look at how the other PRs did this, see eg https://github.com/pandas-dev/pandas/pull/19999/files 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. Sounds good, I will update that information. |
||
|
||
Examples | ||
-------- | ||
>>> s = pd.Series([2, 3, np.nan, 'values']) | ||
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. 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. 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 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! |
||
>>> 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 | ||
""") | ||
|
||
def count(self): | ||
|
||
|
@@ -1199,7 +1232,6 @@ def aggregate(self, arg, *args, **kwargs): | |
agg = aggregate | ||
|
||
@Substitution(name='rolling') | ||
@Appender(_doc_template) | ||
@Appender(_shared_docs['count']) | ||
def count(self): | ||
|
||
|
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.
Using the word
sum
is confusing here for acount
. Can you reword to the effect of "count of non-NaN
observations..."?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.
"count of non-Nan observations inside the rolling window" would work?
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.
Yes
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.
@scriptomation be sure that you actually surround your reference to
NaN
in back ticks, so literally you would write non-`NaN` (capitalization matters too)