from sklearn.preprocessing import LabelEncoder le = LabelEncoder() companydata.ShelveLoc = le.fit_transform(companydata.ShelveLoc)