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 -
Python 2021-10-14 21:29:08
Python pandas how to drop a column
df = pd.DataFrame(np.arange(12).reshape(3, 4), columns=['A', 'B', 'C', 'D']) >>> df A B C D 0 0 1 2 3 1 4 5 6 7 2 8 9 10 11 cols=['B', 'C'] >>> df.drop(columns = cols) # or # df.drop(columns = ['B', 'C']) A ... Add solution