Python--TypeError: ‘<‘ not supported between instances of ‘str‘ and ‘float‘

Label encodeing 遇到的错误

错误图示:

Python--TypeError: ‘<‘ not supported between instances of ‘str‘ and ‘float‘

 代码没有错误,主要是数据处理错误。

将字符类型利用label encoding 映射成 数字,但是数据原本有缺失。

题主将其全部替换成了0,但是不能够同时处理字符串和数值的类型。

因此将原本的0,全部又替换成了字符“a”,得到了解决。