Last active
November 3, 2022 07:57
-
-
Save bkaankuguoglu/622bdfdd6c8e88c67d5fa677389f09ed 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 onehot_encode_pd(df, col_name): | |
| dummies = pd.get_dummies(df[col_name], prefix=col_name) | |
| return pd.concat([df, dummies], axis=1).drop(columns=[col_name]) | |
| df_features = onehot_encode_pd(df_features, ['month','day','day_of_week','week_of_year']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
`def onehot_encode_pd(df, cols):
for col in cols:
dummies = pd.get_dummies(df[col], prefix=col)
df_features = onehot_encode_pd(df_features, ['month','day','day_of_week','week_of_year'])
df_features`