我有一个像这样的数据帧
studentID subjectID subjectMark subjectWeight Rank overallScore
1 111 100 0.4 3 40
1 222 0 0.6 3 40
2 111 90 0.4 1 90
2 222 90 0.6 1 90
3 111 0 0.4 2 60
3 222 100 0.6 2 60
如你所见,学生1和3在某些科目上都取得了很高的成绩,但他们的总成绩很差,而学生2在任何科目上都没有取得任何最高的成绩,但总成绩最好
总分=科目111分*科目111权重+科目222分*科目222权重
所以我想看看某个学生是否是“全能者”,也就是说,我想看看这个学生的总分是否最高,但在任何科目上都没有最高分。如果符合这个条件,就给这个学生贴上“全能”的标签
df应该是这样的:
studentID subjectID subjectMark subjectWeight Rank overallScore AR
1 111 100 0.4 3 40 F
1 222 0 0.6 3 40 F
2 111 90 0.4 1 90 T
2 222 90 0.6 1 90 T
3 111 0 0.4 2 60 F
3 222 100 0.6 2 60 F
我有一个后续问题
给出的答案可以在最后一个数据帧上实现,但是如果我想在接下来的数据帧中的每个类上都实现这个功能呢?你知道吗
studentID subjectID subjectMark subjectWeight Rank overallScore classID
1 111 100 0.4 3 40 1
1 222 0 0.6 3 40 1
2 111 90 0.4 1 90 1
2 222 90 0.6 1 90 1
3 111 0 0.4 2 60 1
3 222 100 0.6 2 60 1
4 444 95 0.4 3 38 2
4 555 0 0.6 3 38 2
5 444 90 0.4 1 90 2
5 555 90 0.6 1 90 2
6 444 0 0.4 2 57 2
6 555 95 0.6 2 57 2
我已经找到了一个解决这个问题的方法,尽管这可能是实现这个目标的最好(最干净的)方法
你可以查一下
相关问题 更多 >
编程相关推荐