# We can use label encoding on multiple column at once by using method from sklearn.preprocessing import LabelEncoder df[cat_c] = df[cat_c].apply(LabelEncoder().fit_transform)