Answers for "convert categorical column type to int in pandas"

1

panda categorical data into numerica

sex = train_dataset['Sex'].replace(['female','male'],[0,1])
print(sex)
Posted by: Guest on March-04-2021
0

convert categorical data type to int in pandas

from sklearn import preprocessing

lab_encoder = preprocessing.LabelEncoder()
df['column'] = lab_encoder.fit_transform(df['column'])
Posted by: Guest on November-09-2021

Code answers related to "convert categorical column type to int in pandas"

Browse Popular Code Answers by Language