i have a dataframe with students and their school subjects:
Subject | Mark |
---|---|
Helen | |
Art | 20 |
Philosophy | 16.8 |
Economics | 12 |
Colin | |
Maths | 19.2 |
Geography | 17 |
History | 15 |
For every subject, there is a different weighting, which changes by semester and affects the student’s total:
Subject | Weight |
---|---|
Art | 0.1 |
Philosophy | 0.6 |
Economics | 0.2 |
Maths | 0.5 |
Geography | 0.01 |
Philosophy | 0.5 |
History | 0.3 |
Maths | 0.6 |
i was thinking of implementing some sort of vlook up wing the join method, but then since the weightings change, i would have to update the table.
However i would like to print the output in a file as i go through the weights table. in that case, i understand i can use for loops but that is not the most optimised method.
Is there any type of lamda i can use for this case?
Additionally is there any way to identify when each student’s total changes, and output that? I was thinking creating sub groups from the data frame and then checking the cumulative sum?
Essentially while iterating through the weights table above, i would like my output to be:
Subject = Mark*Weight but to also account and track the changes in the student totals, so:
Art: 0.2
Philosophy: 10.08
Economics: 2.4
Helen: 12.68
Maths: 9.6
Geography: 0.17
Philosophy:8.4
Helen:11
History:4.5
Colin: 14.27
Maths:11.52
Colin:16.19