Answers for "one hot enconding pthon dataframe"

4

one hot encoding python pandas

y = pd.get_dummies(df.Countries, prefix='Country')
print(y.head())
# from here you can merge it onto your main DF
Posted by: Guest on May-12-2020
0

onehot encode list of columns pandas

from sklearn.preprocessing import MultiLabelBinarizer

mlb = MultiLabelBinarizer()
df = df.join(pd.DataFrame(mlb.fit_transform(df.pop('Col3')),
                          columns=mlb.classes_,
                          index=df.index))
Posted by: Guest on June-05-2020

Code answers related to "one hot enconding pthon dataframe"

Python Answers by Framework

Browse Popular Code Answers by Language