I have a pandas DataFrame as following, showing the scores of students in multiple subjects:
Name Subject Score
0 Tom A 91
1 Tom B 92
2 Tom C 93
3 Bob A 94
4 Bob C 95
5 Ali B 96
6 Ali C 97
Note that not every student has scores in all subjects. I want to pivot it into a DataFrame like this:
Name A B C
0 Tom 91 92 93
1 Bob 94 95
2 Ali 96 97
The goals to achieve in this pivot:
- group the scores by 'Name'
- insert columns of subjects
- arrange the scores at the crossing space of Name and subjects
I'm new to pandas but I looked into DataFrame.pivot_table(), while unfortunately couldn't figure out the right way.
