【发布时间】:2018-07-14 18:25:17
【问题描述】:
考虑以下数据框:
import pandas as pd
from sklearn.preprocessing import LabelEncoder
df = pd.DataFrame(data=[["France", "Italy", "Belgium"], ["Italy", "France", "Belgium"]], columns=["a", "b", "c"])
df = df.apply(LabelEncoder().fit_transform)
print(df)
目前输出:
a b c
0 0 1 0
1 1 0 0
我的目标是通过传入我想要共享分类值的列来使其输出类似的内容:
a b c
0 0 1 2
1 1 0 2
【问题讨论】:
标签: python pandas scikit-learn