Created
July 20, 2019 02:36
-
-
Save kperry2215/f9fc8ed4a64073e15f197c049086c794 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def decompose_time_series(series): | |
""" | |
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') | |
result.plot() | |
pyplot.show() | |
#Execute in the main block | |
#Convert the Date column into a date object | |
electricity_df['Date']=pd.to_datetime(electricity_df['Date']) | |
#Set Date as a Pandas DatetimeIndex | |
electricity_df.index=pd.DatetimeIndex(electricity_df['Date']) | |
#Decompose the time series into parts | |
decompose_time_series(electricity_df['Electricity_Price']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment