Created
November 22, 2020 22:00
-
-
Save alexrios22/3ccc0e3ba38d0bb101a17b545eb3efcd to your computer and use it in GitHub Desktop.
SeasonalDecompose.ibpynb
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
import statsmodels.api as sm | |
decomposition = sm.tsa.seasonal_decompose(data['Adj Close'], model="additive", period = 253) | |
trend = decomposition.trend | |
seasonal = decomposition.seasonal | |
residual = decomposition.resid | |
fig, axs = plt.subplots(4, figsize=(14, 10), sharex=True) | |
data['Adj Close'].plot(title='Original', color="blue", ax=axs[0]) | |
trend.plot(title='Trend', color="red", ax=axs[1]) | |
seasonal.plot(title='Seasonality', color="orange", ax=axs[2]) | |
residual.plot(title='Residuals', color="green", ax=axs[3]) | |
plt.tight_layout();seasonal["2019"].plot(label='Seasonality', color="blue", figsize=(20,8)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment