📜  labelencoder 更新 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:06.333000             🧑  作者: Mango

代码示例1
# train and test are pandas.DataFrame's and c is whatever column
le = LabelEncoder()
le.fit(train[c])
test[c] = test[c].map(lambda s: '' if s not in le.classes_ else s)
le.classes_ = np.append(le.classes_, '')
train[c] = le.transform(train[c])
test[c] = le.transform(test[c])