categorical feature label encoding code example
Example 1: pandas categorical to numeric
#this will label the different catagories as 0,1,2,3....
dataset["sex"] = dataset["sex"].astype('category').cat.codes
Example 2: label encoding
from sklearn.preprocessing import LabelEncoder
le = LabelEncoder()
companydata.ShelveLoc = le.fit_transform(companydata.ShelveLoc)