-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Updating Series.autocorr docstring #22787
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
1e200ac
ae96704
f0aae5d
082262b
99e7637
33dcb33
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 |
---|---|---|
|
@@ -2021,7 +2021,10 @@ def diff(self, periods=1): | |
|
||
def autocorr(self, lag=1): | ||
""" | ||
Lag-N autocorrelation | ||
Compute the lag-N autocorrelation. | ||
|
||
This method computes the pearson correlation between | ||
the Series and its shifted self. | ||
|
||
Parameters | ||
---------- | ||
|
@@ -2030,7 +2033,33 @@ def autocorr(self, lag=1): | |
|
||
Returns | ||
------- | ||
autocorr : float | ||
float | ||
The Pearson correlation between self and self.shift(lag). | ||
|
||
See also | ||
-------- | ||
Series.corr : Compute the correlation between two Series. | ||
|
||
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. Add Series.shift, DataFrame.corr and DataFrame.corrwith |
||
Notes | ||
----- | ||
return Nan if the computation of the autocorr is not possible. | ||
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. Perhaps say something like if the correlation is not defined. Nan should be written as
|
||
|
||
Examples | ||
-------- | ||
>>> s = pd.Series([0.25, 0.5, 0.2, -0.05]) | ||
>>> s.autocorr() | ||
0.1035526330902407 | ||
>>> s.autocorr(lag=2) | ||
-0.9999999999999999 | ||
|
||
**Warning** | ||
|
||
If the pearson correlation between self and self.shift(lag) cannot be | ||
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. Rather than "self" and "self.shift(lag)", how about "If the Pearson correlation between the two points is not defined, then ``NaN`` is returned. |
||
computed, then nan is returned. | ||
|
||
>>> s = pd.Series([1, 0, 0, 0]) | ||
>>> s.autocorr() | ||
nan | ||
""" | ||
return self.corr(self.shift(lag)) | ||
|
||
|
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.
Does the "A" in also need to be capitalized?