需要从一个热编码形状检索原始数据形状
我收到了一个数据集,其中包括先前转换为一个热编码的列。我想检索其旧形状以进行一些预处理和填充NAS方法,当然也可以阅读数据集的统计模型。
我得到的数据列:
team2_offistion_derived_var_0 | team2_offistion_derived_derived_var_1 | team2_offistion_derived_derived_var_var_2 | team2_offence_derives_derived_derived_var_3 | team2_offistion_derived_derives_var_var_4 | team2_offensive_derived_var_9 | team2_offensive_derives_var_10 | team2 | 0 | 0 | 0 0 0 0 0 0 0 |
---|---|---|---|---|---|---|---|---|---|---|
0 0 | 0 0 | 0 0 | 0 | 0 | 0 | 0 0 | 0 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 0 0 0 0 0 | 0 0 | 0 | 0 | 0 |
0 0 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 0 | 1 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 0 | 0 | 0 | 0 | 0 | 0 | 0 0 | 0 |
0 0 0 | 0 | 0 | 0 | 0 | 0 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 我 | 0 |
0 | 0 | 0 | 0 | 0 0 | 0 0 | 0 0 0 | 0 | 0 | 0 0 | 0 0 0 |
0 0 | 0 0 0 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
想将其形状转换为
row_id | team2_offissives_ferived |
---|---|
0 | var 10 var 10 |
1 | var 9 |
2 | var 8 |
3 | var 7 |
4 | var 6 |
5 | var 5 |
6 | var 4 |
7 | var 3 |
8 | var 2 |
9 | var 1 |
10 | var 0 |
列,例如:
team2_other_ratio_var_42 | team2 team2_other_ratio_var_43 | _other_ratio_var_48 | team2_other_ratio_var_49 | team2_other_ratio_var_50 | team2_other_ratio_var_51 | team2_other_ratio_var_52 | i还 | 0.0 | 一个 | 0.0 |
---|---|---|---|---|---|---|---|---|---|---|
获得了 | 0.400 | 0.200 | 0.000 | 0.750 | 0.250 | 0.341121 | 0.375 | 0.354167 | 0.184211 | 0.000 |
,但我很困惑如何将其检索到原始形状? “分类”,但我不知道如何?
谢谢大家的帮助
I received a dataset that include columns that previously transformed into one hot encoded. And I want to retrieve the old shape of it to do some preprocessing and filling NAs methods and of course read the stats model of the dataset.
The data columns I got:
team2_offensive_derived_var_0 | team2_offensive_derived_var_1 | team2_offensive_derived_var_2 | team2_offensive_derived_var_3 | team2_offensive_derived_var_4 | team2_offensive_derived_var_5 | team2_offensive_derived_var_6 | team2_offensive_derived_var_7 | team2_offensive_derived_var_8 | team2_offensive_derived_var_9 | team2_offensive_derived_var_10 |
---|---|---|---|---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
I want to transform it's shape into
row_id | team2_offensive_derived |
---|---|
0 | var 10 |
1 | var 9 |
2 | var 8 |
3 | var 7 |
4 | var 6 |
5 | var 5 |
6 | var 4 |
7 | var 3 |
8 | var 2 |
9 | var 1 |
10 | var 0 |
I also got a columns like:
team2_other_ratio_var_42 | team2_other_ratio_var_43 | team2_other_ratio_var_44 | team2_other_ratio_var_45 | team2_other_ratio_var_46 | team2_other_ratio_var_47 | team2_other_ratio_var_48 | team2_other_ratio_var_49 | team2_other_ratio_var_50 | team2_other_ratio_var_51 | team2_other_ratio_var_52 |
---|---|---|---|---|---|---|---|---|---|---|
0.0 | 0.400 | 0.200 | 0.000 | 0.750 | 0.250 | 0.341121 | 0.375 | 0.354167 | 0.184211 | 0.000 |
But I'm confused how should I retrieve it to it's original shape? "Categorical" But I don't know how?
Thank you all for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
stack
:输出:
具有不同的列名称:
输出:
You can use a
stack
:output:
With different column names:
output:
使用:
Use: