Average score per student per subject, with gaps filled
Your task
Given marks with columns student, subject and score, build a table of the MEAN score for every student and subject pair, using 0 where a pair is missing. Return student, math and science, sorted by student ascending.
Examples
mean_grid(marks: dataframe) -> dataframeExample 1
Input
mean_grid(marks)marks
| student | subject | score |
|---|---|---|
| ana | math | 88 |
| ana | science | 92 |
| ben | math | 75 |
| ben | science | 64 |
| cara | math | 95 |
| cara | science | 81 |
| ana | math | 100 |
Output
| student | math | science |
|---|---|---|
| ana | 94 | 92 |
| ben | 75 | 64 |
| cara | 95 | 81 |