File tree 1 file changed +32
-2
lines changed
1 file changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -2035,7 +2035,10 @@ def diff(self, periods=1):
2035
2035
2036
2036
def autocorr (self , lag = 1 ):
2037
2037
"""
2038
- Lag-N autocorrelation
2038
+ Compute the lag-N autocorrelation.
2039
+
2040
+ This method computes the Pearson correlation between
2041
+ the Series and its shifted self.
2039
2042
2040
2043
Parameters
2041
2044
----------
@@ -2044,7 +2047,34 @@ def autocorr(self, lag=1):
2044
2047
2045
2048
Returns
2046
2049
-------
2047
- autocorr : float
2050
+ float
2051
+ The Pearson correlation between self and self.shift(lag).
2052
+
2053
+ See Also
2054
+ --------
2055
+ Series.corr : Compute the correlation between two Series.
2056
+ Series.shift : Shift index by desired number of periods.
2057
+ DataFrame.corr : Compute pairwise correlation of columns.
2058
+ DataFrame.corrwith : Compute pairwise correlation between rows or
2059
+ columns of two DataFrame objects.
2060
+
2061
+ Notes
2062
+ -----
2063
+ If the Pearson correlation is not well defined return 'NaN'.
2064
+
2065
+ Examples
2066
+ --------
2067
+ >>> s = pd.Series([0.25, 0.5, 0.2, -0.05])
2068
+ >>> s.autocorr()
2069
+ 0.1035526330902407
2070
+ >>> s.autocorr(lag=2)
2071
+ -0.9999999999999999
2072
+
2073
+ If the Pearson correlation is not well defined, then 'NaN' is returned.
2074
+
2075
+ >>> s = pd.Series([1, 0, 0, 0])
2076
+ >>> s.autocorr()
2077
+ nan
2048
2078
"""
2049
2079
return self .corr (self .shift (lag ))
2050
2080
You can’t perform that action at this time.
0 commit comments