Last active
October 31, 2020 20:54
-
-
Save erraticgenerator/29292524b9db891989f7a5a9eebef47a to your computer and use it in GitHub Desktop.
This file contains 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
mlb = MultiLabelBinarizer() | |
# one-hot encoding + prefix | |
df = df.join(pd.DataFrame(mlb.fit_transform(df.pop('variants')), | |
columns=[x for x in mlb.classes_], | |
index=df.index)) | |
df = df.join(pd.DataFrame(mlb.fit_transform(df.pop('subsets')), | |
columns=['subsets_' + x for x in mlb.classes_], | |
index=df.index)) | |
df = df.join(pd.get_dummies(df['category'], prefix="category")).drop(['category'], axis=1) | |
df.head(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment