0

I have set a list of categories in my ordinalEncoder

noemployees_encoder=OrdinalEncoder(categories= [["1-5","6-25","26-100","100-500","500-1000","More than 1000"]])
mh_dataclean_encoded["no_employees"]=noemployees_encoder.fit_transform(mh_dataclean_encoded[["no_employees"]])

Afterwards when I call fit_transform method I get the following error:

could not convert string to float: '1-5'

I've followed some OrdinalEncoder tutorials and it apparently seems ok. Any help?

1 Answer 1

1

try to change the dtype of your data like this

noemployees_encoder=OrdinalEncoder(categories= [["1-5","6-25","26-100","100-500","500-1000","More than 1000"]],dtype=np.str_)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.