w3resource
Pandas Tutorial

Pandas Series: autocorr() function

Compute the lag-N autocorrelation in Pandas

The autocorr() function is used to compute the lag-N autocorrelation.

This method computes the Pearson correlation between the Series and its shifted self.

Syntax:

Series.autocorr(self, lag=1)

Parameters:

Name Description Type/Default Value Required / Optional
lag Number of lags to apply before performing autocorrelation. int
Default Value: 1
Required

Returns: float
The Pearson correlation between self and self.shift(lag)

Notes: If the Pearson correlation is not well defined return ‘NaN’.

Example:


Download the above Notebook from here.