ComenzarEmpieza gratis

Autocorrelation in time series data

In the field of time series analysis, autocorrelation refers to the correlation of a time series with a lagged version of itself. For example, an autocorrelation of order 3 returns the correlation between a time series and its own values lagged by 3 time points.

It is common to use the autocorrelation (ACF) plot, also known as self-autocorrelation, to visualize the autocorrelation of a time-series. The plot_acf() function in the statsmodels library can be used to measure and plot the autocorrelation of a time series.

Este ejercicio forma parte del curso

Visualizing Time Series Data in Python

Ver curso

Instrucciones del ejercicio

  • Import tsaplots from statsmodels.graphics.
  • Use the plot_acf() function from tsaplots to plot the autocorrelation of the 'co2' column in co2_levels.
  • Specify a maximum lag of 24.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Import required libraries
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
from ____ import ____

# Display the autocorrelation plot of your time series
fig = ____(co2_levels[____], lags=____)

# Show plot
plt.show()
Editar y ejecutar código