-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
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 1 commit
101f14a
38e5787
a2bde20
1151e10
61dff85
dd61858
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
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. | ||||
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 know this is copied from the DataFrame/Series one, but I personally don't find "kurtosis of normal == 0.0" very clear. I suppose it is about a normal distribution having a kurtosis of 0.0 ? |
||||
|
||||
Returns | ||||
------- | ||||
same type as input | ||||
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. Again, I know this was already there ..:) But I also find this not very clear. What is the "input"? As I didn't provide anything to the function .. (it's rather the object calling rolling) But not directly sure how to document this very well. Maybe just "Series/DataFrame" (depending on the calling object) 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 when I did this originally I had: Series or DataFrame
Like-indexed object containing the result of the kurt operation However, I ended up with the above because all of the other rolling / expanding functions used this in the Line 51 in aedbd94
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 we should break the consistency for now, with the idea that if all those docstrings get updated during the sprint, we should strive again for consistency with the new wording? Or indeed already update the template, then it is changed for all as well. In any case I think we should try to make the docstring that you are now editing, as good as possible. |
||||
|
||||
See Also | ||||
-------- | ||||
scipy.stats.kurtosis | ||||
pandas.DataFrame.kurtosis | ||||
pandas.Series.kurtosis | ||||
|
||||
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. period at and |
||||
|
||||
Examples | ||||
-------- | ||||
>>> arr = [1, 2, 3, 4, 5] | ||||
>>> import scipy.stats | ||||
>>> scipy.stats.kurtosis(arr, bias=False) | ||||
-1.200000000000000 | ||||
|
||||
>>> 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. Can you put a small explanation? Very dummy saying what the example is doing |
||||
>>> df.rolling(5).kurt() | ||||
0 | ||||
0 NaN | ||||
1 NaN | ||||
2 NaN | ||||
3 NaN | ||||
4 -1.2 | ||||
""") | ||||
|
||||
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.
I think by using
dedent
, you can actually keep this indented (so it doesn't look that 'off' inside the class)(I am not even sure the
dedent
is needed, as there are many places where we don't use it, but that is something else)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.
Yep mistake on initial push. Subsequently indented in the next push