-1
$\begingroup$

I have a dataframe with integer and categorical variables. Should I label encode all variables (both integer and categorical) or should I encode only the categorical features?

$\endgroup$
0
$\begingroup$

You only need to label encode the categorical features. For e.g. if the first column contains categorical data then you can do something like shown below-

from sklearn.preprocessing import LabelEncoder
labelencoder = LabelEncoder()
x[:, 0] = labelencoder.fit_transform(x[:, 0])
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.