One-hot encoding replaces a categorical column with one binary column per distinct value; each row carries a single 1. A color column of red, green, and blue becomes three columns.
df["color"].nunique() # 3
pd.get_dummies(df, columns=["color"]).shape # (1000, 12), was (1000, 10)
Dimensionality grows with cardinality, not with row count. One column of k values costs k columns. Three columns of 100 values each add 300, and the resulting matrix is over 99 percent zeros.
That width costs memory and fit time, and it hurts trees in particular. A tree splits one column at a time, so a category spread across 100 binary columns needs depth to isolate. Sparse storage fixes the memory, not the depth. Past a few dozen values, reach for another encoding.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓