Python LableEncoder()错误(sklearn)

Python LableEncoder()错误(sklearn),python,python-3.x,dataframe,scikit-learn,Python,Python 3.x,Dataframe,Scikit Learn,如何在python 3.0(Anaconda)中处理LableEncoder()?当我运行我的数据时,我得到一个类似于“的错误,让我们尝试下面的代码: from sklearn import preprocessing le =preprocessing.LabelEncoder() le.fit_transform(['Gender','Married','Dependents','Education','Self_Employed', 'Property_Area','Loan_Status

如何在python 3.0(Anaconda)中处理
LableEncoder()
?当我运行我的数据时,我得到一个类似于
“的错误,让我们尝试下面的代码:

from sklearn import preprocessing
le =preprocessing.LabelEncoder()
le.fit_transform(['Gender','Married','Dependents','Education','Self_Employed', 'Property_Area','Loan_Status'])
keys = le.classes_
values = le.transform(le.classes_)
df = dict(zip(keys, values))
print(df)

请发布错误的完整堆栈跟踪以及发生错误的
i
值。我怀疑在
I
列中是否有不同类型的值

如果可以将数据转换为所有字符串,请尝试以下操作:

for i in var_mod:
    df[i] = le.fit_transform(df[i].astype(str))

df
的内容是什么?你为什么不做
le.fit\u变换(var\u mod)
?还有,你为什么在你的问题中遗漏了至关重要的信息?别担心?它的公共数据集可供所有人使用。可能是我的qtn不清楚……这里有‘性别’、‘已婚’、‘教育’。。etc是数据集中的列,具有不同的变量,如“已婚”和“未已婚”等。。。所以我想在这些列上应用LabelineCoder,这些列将反映在我的数据集上。。。谢谢
for i in var_mod:
    df[i] = le.fit_transform(df[i].astype(str))