【发布时间】:2018-12-13 22:14:53
【问题描述】:
您好,我有一个学生数据集,其中包含他们的姓名、科目和分数。
每个学生有 5 个科目要写。然而,下表缺少一些学生在科目和分数方面的数据。请查看下表:
Name Subject Score
Harry Math 4
Harry Science 5
Harry Social 3
Harry French 5
Harry Spanish 4
Steve Math 5
Steve Science 3
Steve Social 5
Steve French 4
Tom Math 5
Tom Science 4
Tom Social 5
我想查找分数少于 5 个科目的姓名并附加额外的行,以便所有学生都有他们所有 5 个科目的个人分数。预期输出如下:
Name Subject Score
Harry Math 4
Harry Science 5
Harry Social 3
Harry French 5
Harry Spanish 4
Steve Math 5
Steve Science 3
Steve Social 5
Steve French 4
Steve Spanish 4
您可以在此处看到 Steve、Harry 和 Tom 在所有 5 个科目上都有分数。
【问题讨论】:
-
如何为添加的行得出分数?
-
我有用于填充数据的原始数据
标签: python pandas sorting pandas-groupby