0
Q:

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
2
from sklearn.preprocessing import MultiLabelBinarizer

mlb = MultiLabelBinarizer()
df = df.join(pd.DataFrame(mlb.fit_transform(df.pop('Col3')),
                          columns=mlb.classes_,
                          index=df.index))
0

New to Communities?

Join the community