How to One-Hot Encode a Column with OneHotEncoder in scikit-learn
Models do arithmetic, so a column of words such as red, green and blue has to become numbers first. One-hot encoding gives every word its own column, holding 1 where a row has that word and 0 elsewhere. scikit-learn's OneHotEncoder does it, and remembers the words it saw so new data is encoded the same way. This guide encodes a small column of colors, with real output from scikit-learn 1.9.1.
