Skip to content

Instantly share code, notes, and snippets.

@kperry2215
Last active August 1, 2019 04:42
Show Gist options
  • Save kperry2215/5856e799805327bf895f6b221d199fea to your computer and use it in GitHub Desktop.
Save kperry2215/5856e799805327bf895f6b221d199fea to your computer and use it in GitHub Desktop.
#Subset the dataframe to only include the features and labels that we're going to use
#in the model
peak_demand_hour_model=peak_demand_hour_df[['Peak_Demand_Hour',
'Day_Of_Week',
'Week',
'Month']]
#Convert the Week, Year, and Peak_Demand_Your variables into categorical string variables (from numeric)
peak_demand_hour_model.loc[:,'Week']=peak_demand_hour_model['Week'].apply(str)
peak_demand_hour_model.loc[:,'Peak_Demand_Hour']='Hour '+peak_demand_hour_model['Peak_Demand_Hour'].apply(str)
#Remove the labels from the features
features= peak_demand_hour_model.drop('Peak_Demand_Hour', axis = 1)
#One hot encode the categorical features
features = pd.get_dummies(features)
#Create labels
labels = np.array(peak_demand_hour_model['Peak_Demand_Hour'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment