import warnings
import itertools
import numpy as np
import matplotlib.pyplot as plt
warnings.filterwarnings("ignore")
plt.style.use('fivethirtyeight')
import pandas as pd
import statsmodels.api as sm
import matplotlib
matplotlib.rcParams['axes.labelsize'] = 14
matplotlib.rcParams['xtick.labelsize'] = 12
matplotlib.rcParams['ytick.labelsize'] = 12
matplotlib.rcParams['text.color'] = 'k'
df = pd.read_excel("Superstore.xls")
furniture = df.loc[df['Category'] == 'Furniture']
furniture = furniture.set_index('Order Date')
y = furniture['Sales'].resample('MS').mean()
y.plot(figsize=(15, 6))
plt.show()
import matplotlib as mpl
with mpl.rc_context():
mpl.rc("figure", figsize=(18,8))
decomposition = sm.tsa.seasonal_decompose(y, model='additive', freq=12)
decomposition.plot()
plt.show()
note.nkmk.me
https://towardsdatascience.com/an-end-to-end-project-on-time-series-analysis-and-forecasting-with-python-4835e6bf050b
Seasonality in Python: additive or multiplicative model?