Skip to content

Instantly share code, notes, and snippets.

@pkgandhi
Created August 10, 2020 01:32
Show Gist options
  • Save pkgandhi/71163b983b8e8e98cf1006c81c417fb1 to your computer and use it in GitHub Desktop.
Save pkgandhi/71163b983b8e8e98cf1006c81c417fb1 to your computer and use it in GitHub Desktop.
Autocorrelation and Partial Autocorrelation Plot
# Loading the packages
import pandas as pd
from statsmodels.graphics import tsaplots
plt.style.use('fivethirtyeight')
# Loading the dataset:
data = pd.read_csv('../AirPassengers.csv')
data = data.rename(columns = {'#Passengers':'Passengers'})
data = data.set_index('Month')
# Display the autocorrelation plot of your time series
fig = tsaplots.plot_acf(data, lags=24)
plt.show()
# Display the partial autocorrelation plot of your time series
fig = tsaplots.plot_pacf(data, lags=24)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment