Skip to content

Instantly share code, notes, and snippets.

@kperry2215
Created January 4, 2020 23:31
Show Gist options
  • Save kperry2215/e8a01ac88adc60770b8690ea411ed0a9 to your computer and use it in GitHub Desktop.
Save kperry2215/e8a01ac88adc60770b8690ea411ed0a9 to your computer and use it in GitHub Desktop.
from statsmodels.tsa.seasonal import seasonal_decompose
def decompose_time_series(series, frequency):
"""
Decompose a time series and plot it in the console
Arguments:
series: series. Time series that we want to decompose
Outputs:
Decomposition plot in the console
"""
result = seasonal_decompose(series, model='additive', freq = frequency)
result.plot()
plt.show()
### EXECUTE IN MAIN FUNCTION ###
#Decompose the time series to determine seasonality/trend
decompose_time_series(df['Geothermal_net_generation'], 12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment