pandas one-hot encoding code example
Example 1: 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
Example 2: get_dummies python
>>> pd.get_dummies(s)
a b c
0 1 0 0
1 0 1 0
2 0 0 1
3 1 0 0