Created
March 29, 2021 23:25
-
-
Save bkaankuguoglu/8d390eaf87c1459cb016be300bf2e09b 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
| from sklearn.compose import ColumnTransformer | |
| from sklearn.preprocessing import OneHotEncoder | |
| def onehot_encode(df, onehot_columns): | |
| ct = ColumnTransformer( | |
| [('onehot', OneHotEncoder(drop='first'), onehot_columns)], | |
| remainder='passthrough' | |
| ) | |
| return ct.fit_transform(df) | |
| onehot_columns = ['hour'] | |
| onehot_encoded = onehot_encode(df_features, onehot_columns) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment