Closed. This question is
off-topic。它当前不接受答案。
想改善这个问题吗?
Update the question,所以它是
on-topic,用于堆栈溢出。
2年前关闭。
我正在使用Py2.7的Spyder IDE处理数据集。
作为标记数据的一部分,我遇到了此错误
X = edm.drop('Class', axis=1)
y = edm['Class']
# Encoding our categorical columns in X
labelEncoder = LabelEncoder()
cat_columns = X.dtypes.pipe(lambda x: x[x == 'object']).index
for col in cat_columns:
X[col] = labelEncoder.fit_transform(X[col])
# Train Test Split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3,
random_state=52)
错误:
File "<ipython-input-18-29fe5821f586>", line 5, in <module>
labelEncoder = LabelEncoder()
NameError: name 'LabelEncoder' is not defined