常用操作 / 深度学习 / 默认 · 3月 9, 2022 0

pandas数据批量标签编码

内容纲要

批量标签编码

from sklearn import preprocessing
le = preprocessing.LabelEncoder()
for i in range(0,X.shape[1]):
if X.dtypes[i]=='object':
X[X.columns[i]] = le.fit_transform(X[X.columns[i]])

https://stackoverflow.com/questions/24458645/label-encoding-across-multiple-columns-in-scikit-learn

%d 博主赞过: