Skip to content

Instantly share code, notes, and snippets.

@saimadhu-polamuri
Created October 17, 2023 02:35
Show Gist options
  • Save saimadhu-polamuri/3d8b6fc5b4425e01ba107dcfd01d1d9c to your computer and use it in GitHub Desktop.
Save saimadhu-polamuri/3d8b6fc5b4425e01ba107dcfd01d1d9c to your computer and use it in GitHub Desktop.
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