Explore Library
Code QuizIntermediate

One-Hot Encoding a Category Column

Spot the bug that stacks one-hot columns as extra rows instead of joining them.

Codepython
import pandas as pd

df = pd.DataFrame({'city': ['NY', 'LA', 'SF']})

encoded = pd.get_dummies(df['city'])
df = pd.concat([df, encoded])
print(df)

What is the bug in this one-hot encoding code?