One-hot knowledge check
A frequency table from a categorical pandas Series for a person's favorite soda is shown.
Coke 1221
Pepsi 1117
NaN 21
If one-hot encoding is completed only on this column, and this is the only column in the dataset, how many columns will be in the final dataset?
Example code:
soda_onehot = pd.get_dummies(
soda[["favorite_soda"]],
columns=["favorite_soda"]
)
This exercise is part of the course
Working with Categorical Data in Python
Hands-on interactive exercise
Turn theory into action with one of our interactive exercises
