from sklearn import preprocessing lab_encoder = preprocessing.LabelEncoder() df['column'] = lab_encoder.fit_transform(df['column'])