Created
October 17, 2023 02:35
-
-
Save saimadhu-polamuri/3d8b6fc5b4425e01ba107dcfd01d1d9c to your computer and use it in GitHub Desktop.
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
from statsmodels.tsa.seasonal import seasonal_decompose | |
# Decompose the time series into its trend, seasonal, and residual components | |
decomposition = seasonal_decompose(data, model='additive') | |
# Plot the decomposed time series | |
fig, ax = plt.subplots() | |
ax.plot(decomposition.trend, label='Trend') | |
ax.plot(decomposition.seasonal, label='Seasonal') | |
ax.plot(decomposition.resid, label='Residual') | |
ax.legend() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment