O'Reilly logo

Python Data Analysis by Ivan Idris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Autocorrelation plots

Autocorrelation plots graph autocorrelations of time series data for different lags. Autocorrelation is the correlation of a time series with the same time series lagged. The autocorrelation_plot() pandas function in pandas.tools.plotting can draw an autocorrelation plot.

The following is the code from the autocorr_plot.py file in this book's code bundle:

import matplotlib.pyplot as plt import numpy as np import pandas as pd from pandas.tools.plotting import autocorrelation_plot df = pd.read_csv('transcount.csv') df = df.groupby('year').aggregate(np.mean) gpu = pd.read_csv('gpu_transcount.csv') gpu = gpu.groupby('year').aggregate(np.mean) df = pd.merge(df, gpu, how='outer', left_index=True, right_index=True) df = df.replace(np.nan, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required