One Hot encoding means splitting categorical variable into multiple binary variables. 

“One hot” means at a time only one feature is Hot/Active out of all the split features. 

In one hot encoding a categorical feature is split into as many features as there are categories in that feature.  

In below example, COLOR is a categorical feature with 3 categories namely red, blue and green,

so new features that are formed from COLOR are COLOR_RED, COLOR_GREEN and COLOR_BLUE. 

Now, if the value of color for an entry was red then COLOR_RED will be assigned value 1 and

 COLOR_GREEN, COLOR_BLUE will be assigned value 0.

 In Pandas categorical features can be one hot encoded by ‘get_dummies’ method. 

# Imports 
import pandas as pd

# Let's create a dataframe
data = {'Color': ['Red', 'Red', 'Green', 'Blue', 'Red', 'Green'],
        'Shape': ['Circle', 'Square', 'Square', 'Triangle', 'Circle', 'Triangle'],
        'Value': [1, 1, 2, 1, 3, 3]}

df = pd.DataFrame(data)
df
ColorShapeValue
0RedCircle1
1RedSquare1
2GreenSquare2
3BlueTriangle1
4RedCircle3
5GreenTriangle3
# Color is a categorical feature having Red, Blue and Green as categories
# Shape is a categorical feature having Circle, Square, Triangle as categories

# Let's get one hot encoded features from Color and Shape
pd.get_dummies(df)
ValueColor_BlueColor_GreenColor_RedShape_CircleShape_SquareShape_Triangle
01001100
11001010
22010010
31100001
43001100
53010001

That's how we do One Hot Encoding | Dummies

That’s all for this mini tutorial. To sum it up, we learned how to do One Hot Encoding | Dummies.

Hope it was easy, cool and simple to follow. Now it’s on you.