How to apply LabelEncoder for a specific column in Pandas dataframe
You can try as following: le = preprocessing.LabelEncoder() df[‘label’] = le.fit_transform(df.label.values) Or following would work too: df[‘label’] = le.fit_transform(df[‘label’]) It will replace original label values in dataframe with encoded labels.