Finding seasonality in time series using autocorrelation plot

The simplest method to check whether there is seasonality in time series data is to plot an autocorrelation graph and just look at it.

Plotting is easy because Pandas has a built-in function which can do it for us. Just pass a single column of a Pandas dataframe as the argument:

from pandas.plotting import autocorrelation_plot

How does it work?

Pandas calculates time lags between values and checks whether values from different dates are correlated. If yes, we may use data from the past to predict a future value. If, additionally the values change in cycles, we assume that some seasonality occurs in the time series.

What are we looking for?

Values near zero indicate that the data is “random” (in this case it means that there is no seasonality). The more the result differs from zero, the more likely some correlation exists.

There is something we are more likely to see in reality than in an online tutorial. This chart indicates some correlation between time lags, but I think that there is no seasonality.

The thing we are looking for is a chart that resembles sine waves. Such a chart indicates that a value strongly correlates with another data point in the future, hence there is seasonality in the dataset.

Ideally, we would see something like this:

Older post

My favourite data science podcasts

I was asked for some podcast recommendation, so here is my very short list ;)

Newer post

Making your Scrapy spider undetectable by applying basic statistics

How to delay scraper requests to make it look like a human visiting the website

Are you looking for an experienced AI consultant? Do you need assistance with your RAG or Agentic Workflow?
Schedule a call, send me a message on LinkedIn, or use the chat button in the right-bottom corner. Schedule a call or send me a message on LinkedIn