Python scikit学习序号编码器错误:无法将字符串转换为浮点

Python scikit学习序号编码器错误:无法将字符串转换为浮点,python,scikit-learn,Python,Scikit Learn,我在我的OrdinalCoder中设置了一个类别列表 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"]])

我在我的OrdinalCoder中设置了一个类别列表

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"]])
之后,当我调用fit_transform方法时,我得到以下错误:

could not convert string to float: '1-5'
我已经学习了一些普通的编码器教程,看起来还不错。
有什么帮助吗?

尝试像这样更改数据的数据类型

noemployees_encoder=OrdinalEncoder(categories= [["1-5","6-25","26-100","100-500","500-1000","More than 1000"]],dtype=np.str_)