Created
July 30, 2019 22:19
-
-
Save kperry2215/4549bbafa0e5488e85639c9714c2498a 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
#Pull the day of month for each reading | |
electricity_demand_df['Day_Of_Month']=electricity_demand_df['Date_Time'].dt.day | |
#Pull the month of the year | |
electricity_demand_df['Month']=electricity_demand_df['Date_Time'].dt.month.apply(lambda x: calendar.month_abbr[x]) | |
#Pull the year | |
electricity_demand_df['Year']=electricity_demand_df['Date_Time'].dt.year | |
#Calculate the hour with max demand for each date in the data set | |
electricity_demand_df['Peak_Demand_Hour_MWh_For_Day']=electricity_demand_df.groupby(['Day_Of_Month', | |
'Month', | |
'Year'], sort=False)['Electricity_Demand_MWh'].transform('max') | |
#Subset time series to only include peak hourly data | |
peak_demand_hour_df=electricity_demand_df[electricity_demand_df[ | |
'Electricity_Demand_MWh']==electricity_demand_df['Peak_Demand_Hour_MWh_For_Day']] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment