Feature Type

  • [X] Adding new functionality to pandas

  • [ ] Changing existing functionality in pandas

  • [ ] Removing existing functionality in pandas

Problem Description

When working with data, I came across the problem when treating the data, when I need to make a Label Encoder, I couldn't do it directly through Pandas, but I had to use another library for that

Feature Description

def labelEncoder(columns): for column in columns: for each different categorical value in column: switch categorical value to number value

Alternative Solutions

from sklearn import preprocessing le = preprocessing.LabelEncoder() le.fit(df.Column) df['Column'] = le.transform(df.Column)

Additional Context

No response

Comment From: mroeschke

Thanks for the suggestion but I would be -1 for including this in pandas since as you mentioned scikit learn has this functionality as is often paired with pandas

Comment From: MarcoGorelli

yeah agreed

and you can already do

df['col1'].astype('category').cat.codes

to get a unique numerical value for each category

closing then, but thanks for the suggestion