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

Lag plots

A lag plot is a scatter plot for a time series and the same data lagged. With such a plot, we can check whether there is a possible correlation between CPU transistor counts this year and the previous year, for instance. The lag_plot() pandas function in pandas.tools.plotting can draw a lag plot. Draw a lag plot with the default lag of 1 for the CPU transistor counts, as follows:

lag_plot(np.log(df['trans_count']))

Refer to the following plot for the end result:

Lag plots

The following code for the lag plot example can also be found in the lag_plot.py file in this book's code bundle:

import matplotlib.pyplot as plt import numpy as np import pandas as ...

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