【发布时间】:2020-05-08 09:57:02
【问题描述】:
train_set 是:
type
0 a
1 b
2 c
3 d
4 e
如果我使用 pd.get_dummies,我会得到 5 列:
type_a type_b type_c type_d type_e
0 1 0 0 0 0
1 0 1 0 0 0
2 0 0 1 0 0
3 0 0 0 1 0
4 0 0 0 0 1
测试集是:
type
0 a
1 b
2 c
3 d
如果我使用 pd.get_dummies,我只会得到 4 列:
type_a type_b type_c type_d
0 1 0 0 0
1 0 1 0 0
2 0 0 1 0
3 0 0 0 1
我希望它是:
type_a type_b type_c type_d type_e
0 1 0 0 0 0
1 0 1 0 0 0
2 0 0 1 0 0
3 0 0 0 1 0
【问题讨论】:
标签: python dataframe dummy-variable