-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update the Rolling.var docstring #20233
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 4 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 |
---|---|---|
|
@@ -879,13 +879,64 @@ def f(arg, *args, **kwargs): | |
ddof=ddof, **kwargs) | ||
|
||
_shared_docs['var'] = dedent(""" | ||
%(name)s variance | ||
Calculate unbiased %(name)s variance. | ||
|
||
Normalized by N-1 by default. This can be changed using the `ddof` | ||
argument. | ||
|
||
Parameters | ||
---------- | ||
ddof : int, default 1 | ||
Delta Degrees of Freedom. The divisor used in calculations | ||
is ``N - ddof``, where ``N`` represents the number of elements.""") | ||
is ``N - ddof``, where ``N`` represents the number of elements. | ||
*args | ||
Under Review. | ||
**kwargs | ||
Under Review. | ||
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.
|
||
|
||
Returns | ||
------- | ||
Series or DataFrame | ||
Returns the same object type as the caller of the %(name)s calculation. | ||
|
||
See Also | ||
-------- | ||
Series.%(name)s : Calling object with Series data | ||
DataFrame.%(name)s : Calling object with DataFrames | ||
Series.var : Equivalent method for Series | ||
DataFrame.var : Equivalent method for DataFrame | ||
numpy.var : Equivalent method for Numpy array | ||
|
||
Notes | ||
----- | ||
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. so in both this one and the std one, should put in the Notes that the ddof default is different than numpy. (we use 1, they use 0). This is in the Series.var/std strings already. 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. 👍 |
||
The default `ddof` of 1 used in Series.var is different than the default | ||
`ddof` of 0 in numpy.var. | ||
|
||
A minimum of 1 periods is required for the rolling calculation. | ||
|
||
Examples | ||
-------- | ||
>>> s = pd.Series([5, 5, 6, 7, 5, 5, 5]) | ||
>>> s.rolling(3).var() | ||
0 NaN | ||
1 NaN | ||
2 0.333333 | ||
3 1.000000 | ||
4 1.000000 | ||
5 1.333333 | ||
6 0.000000 | ||
dtype: float64 | ||
|
||
>>> s.expanding(3).var() | ||
0 NaN | ||
1 NaN | ||
2 0.333333 | ||
3 0.916667 | ||
4 0.800000 | ||
5 0.700000 | ||
6 0.619048 | ||
dtype: float64 | ||
""") | ||
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 show |
||
|
||
def var(self, ddof=1, *args, **kwargs): | ||
nv.validate_window_func('var', args, kwargs) | ||
|
@@ -1257,7 +1308,6 @@ def std(self, ddof=1, *args, **kwargs): | |
return super(Rolling, self).std(ddof=ddof, **kwargs) | ||
|
||
@Substitution(name='rolling') | ||
@Appender(_doc_template) | ||
@Appender(_shared_docs['var']) | ||
def var(self, ddof=1, *args, **kwargs): | ||
nv.validate_rolling_func('var', args, kwargs) | ||
|
@@ -1496,7 +1546,6 @@ def std(self, ddof=1, *args, **kwargs): | |
return super(Expanding, self).std(ddof=ddof, **kwargs) | ||
|
||
@Substitution(name='expanding') | ||
@Appender(_doc_template) | ||
@Appender(_shared_docs['var']) | ||
def var(self, ddof=1, *args, **kwargs): | ||
nv.validate_expanding_func('var', args, kwargs) | ||
|
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.
@jorisvandenbossche ?
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.
It was mentioned that the exact content for what should be documented for args/kwargs was to be determined. If you'd rather me add the documentation I can do that too.
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.
I think we're noting that they're accepted, but not used.