What do you want to save?
Add Code snippet
New code examples
-
Python 2021-10-29 12:16:11
how to use one hot encoding in multiple columns at once
categorical_cols = ['a', 'b', 'c', 'd'] from sklearn.preprocessing import LabelEncoder # instantiate labelencoder object le = LabelEncoder() # apply le on categorical feature columns data[categorical_cols] = data[categorical_cols].apply(lambda col: le.... Add solution