类型错误:'<''float' 和 'str' 的实例之间不支持 [英] TypeError: '<' not supported between instances of 'float' and 'str'

查看:41
本文介绍了类型错误:'<''float' 和 'str' 的实例之间不支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近参加了学习 Python 的课程,在尝试对课程中的数据进行编码时遇到了这个问题.我输入的操作是

I have recently taken course on learning python and I have ran into this issue while trying to encode the data in my lesson. The action I typed in was

# Encoding categorical data

from sklearn.preprocessing import LabelEncoder
labelencoder_X = LabelEncoder()
X[:, 0] = labelencoder_X.fit_transform(X[:, 0])

一旦我将其输入控制台,我就会收到此消息.`类型错误:'<''float' 和 'str' 的实例之间不支持我已经阅读了对类似问题的回答,但我仍然迷失在这里.任何提示都会对我有用.提前致谢.

Once I enter this into the console, I get this message. `TypeError: '<' not supported between instances of 'float' and 'str' I have read responses towards similar questions but I am still at a lost here. Any tips would be of service to me. Thank you in advance.

推荐答案

检查您尝试编码的列是否有任何缺失值或空值.用对我有用的值替换空值和空值行.

Check if the column you are trying to encode has any missing or null values. Replacing the empty and null value rows with values worked for me.

这篇关于类型错误:'&lt;''float' 和 'str' 的实例之间不支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆