Created
August 10, 2020 00:48
-
-
Save pkgandhi/c2babc0071aca3f44a68477d0ae6a32e to your computer and use it in GitHub Desktop.
Decomposition Plot using statsmodels package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Loading the packages | |
import pandas as pd | |
from statsmodels.tsa.seasonal import seasonal_decompose | |
import matplotlib.pyplot as plt | |
# Loading the dataset: | |
data = pd.read_csv('../AirPassengers.csv') | |
data = data.rename(columns = {'#Passengers':'Passengers'}) | |
data = data.set_index('Month') | |
# Plotting the data: | |
rcParams['figure.figsize'] = 9, 7 | |
rcParams['lines.linewidth'] = 0.8 | |
decomposition = seasonal_decompose(data) | |
fig = decomposition.plot() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment