Last active
July 10, 2020 01:54
-
-
Save vanbrands/5fb088b1ba4424a3977f58ca1b453bc9 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
# You have you set of possible categories in a list for example. | |
# (it could be anything really...) | |
possible_categories = ['foo', 'bar] | |
# Convert the categorical column to type Categorical | |
df['categorical_column'] = pd.Categorical( | |
values=df['categorical_column'], | |
categories=possible_categories | |
) | |
dummies = pd.get_dummies(df['categorical_column']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment