Premium problem146. Wide to Long

Easy Locked

scores has columns student_id, math, science and english, one column per subject.

Reshape it to one row per student and subject, with columns student_id, subject and score. Sort by student_id then subject alphabetically, and renumber the index from 0.

Input

   student_id  math  science  english
0           1    90       85       88
1           2    70       75       65

Output

   student_id  subject  score
0           1  english     88
1           1     math     90
2           1  science     85
3           2  english     65
4           2     math     70
5           2  science     75

Premium problem

This one's part of Premium. Unlock the full Pandas track plus every other premium problem on the site.

Implement solve(...)