pandas 1.4.2

NotesParametersReturns
autocorr(self, lag=1) -> 'float'

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

Notes

If the Pearson correlation is not well defined return 'NaN'.

Parameters

lag : int, default 1

Number of lags to apply before performing autocorrelation.

Returns

float

The Pearson correlation between self and self.shift(lag).

Compute the lag-N autocorrelation.

See Also

DataFrame.corr

Compute pairwise correlation of columns.

DataFrame.corrwith

Compute pairwise correlation between rows or columns of two DataFrame objects.

Series.corr

Compute the correlation between two Series.

Series.shift

Shift index by desired number of periods.

Examples

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series([0.25, 0.5, 0.2, -0.05])
... s.autocorr() # doctest: +ELLIPSIS 0.10355...
This example is valid syntax, but we were not able to check execution
>>> s.autocorr(lag=2)  # doctest: +ELLIPSIS
-0.99999...

If the Pearson correlation is not well defined, then 'NaN' is returned.

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series([1, 0, 0, 0])
... s.autocorr() nan
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/series.py#2702
type: <class 'function'>
Commit: