我尝试对包含整数和分类类型的数据框进行encodingLabel
data3:
OFFER customer_class SACC_MARKET_SEGMENT quantity target
0 OM1 ID1 0.0 0 1
我使用此代码执行操作:
from sklearn.preprocessing import LabelEncoder
# LabelEncoder
le = LabelEncoder()
# apply "le.fit_transform"
df_encoded = data3.apply(le.fit_transform)
print(df_encoded)
print(le.classes_)
但是我得到这个错误:
TypeError: ("'<' not supported between instances of 'str' and 'int'", 'occurred at index quantity')
有人可以帮助我解决此问题吗?
谢谢