-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Updated kurt docstring (for pandas sprint) #19999
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 3 commits
101f14a
38e5787
a2bde20
1151e10
61dff85
dd61858
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 |
---|---|---|
|
@@ -899,11 +899,45 @@ def skew(self, **kwargs): | |
return self._apply('roll_skew', 'skew', | ||
check_minp=_require_min_periods(3), **kwargs) | ||
|
||
_shared_docs['kurt'] = """Unbiased %(name)s kurtosis""" | ||
_shared_docs['kurt'] = dedent("""Calculate unbiased %(name)s kurtosis. | ||
|
||
def kurt(self, **kwargs): | ||
This function uses Fisher's definition of kurtosis (kurtosis of normal | ||
== 0.0) without bias. | ||
|
||
Returns | ||
------- | ||
same type as input | ||
|
||
See Also | ||
-------- | ||
scipy.stats.kurtosis | ||
pandas.DataFrame.kurtosis | ||
pandas.Series.kurtosis | ||
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 think it could make sense to add Also, it's probably worth to add 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. Yea I was thinking the same thing about I'll look a little closer to see if there's a scalable way to have all of the functions here reference |
||
|
||
Notes | ||
----- | ||
A minimum of 4 periods is required for the rolling calculation | ||
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. Nice, did you find that the documentation about the "Notes" section made sense for this case? 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 added this from familiarity with the NumPy standard, not necessarily the docs that you built (although they were very helpful on many other aspects - kudos) |
||
|
||
Examples | ||
-------- | ||
>>> arr = [1, 2, 3, 4, 5] | ||
>>> import scipy.stats | ||
>>> scipy.stats.kurtosis(arr, bias=False) | ||
-1.2000000000000004 | ||
|
||
>>> df = pd.DataFrame(arr) | ||
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. Maybe a Series is more natural? (as you don't have a column name) |
||
>>> df.rolling(5).kurt() | ||
0 | ||
0 NaN | ||
1 NaN | ||
2 NaN | ||
3 NaN | ||
4 -1.2 | ||
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. Probably it's obvious enough, but may be having 6 values instead of 5, would give more the idea that after the 4th |
||
""") | ||
|
||
def kurt(self): | ||
return self._apply('roll_kurt', 'kurt', | ||
check_minp=_require_min_periods(4), **kwargs) | ||
check_minp=_require_min_periods(4)) | ||
|
||
_shared_docs['quantile'] = dedent(""" | ||
%(name)s quantile | ||
|
@@ -1221,7 +1255,6 @@ def skew(self, **kwargs): | |
return super(Rolling, self).skew(**kwargs) | ||
|
||
@Substitution(name='rolling') | ||
@Appender(_doc_template) | ||
@Appender(_shared_docs['kurt']) | ||
def kurt(self, **kwargs): | ||
return super(Rolling, self).kurt(**kwargs) | ||
|
@@ -1461,7 +1494,6 @@ def skew(self, **kwargs): | |
return super(Expanding, self).skew(**kwargs) | ||
|
||
@Substitution(name='expanding') | ||
@Appender(_doc_template) | ||
@Appender(_shared_docs['kurt']) | ||
def kurt(self, **kwargs): | ||
return super(Expanding, self).kurt(**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.
It's a somehow arbitrary comment, but to me it'd look better something like:
Series or DataFrame (same as the input) : some description
Or if the
%(name)s
aboveSeries
orDataFrame
depending on in which method is being used? Then we can use it also here.