var_to_encode = ['Device_Type','Filled_Form','Gender','Var1','Var2','Mobile_Verified','Source'] for col in var_to_encode: data[col] = le.fit_transform(data[col])
报错:TypeError: '>' not supported between instances of 'float' and 'str'
修改为:
data[col] = le.fit_transform(data[col].astype(str))亲测可用
参考链接:https://stackoverflow.com/questions/46406720/labelencoder-typeerror-not-supported-between-instances-of-float-and-str