I have a dataframe of the following form:
| Year 1 Grade | Year 2 Grade | Year 3 Grade | Year 4 Grade | Year 1 Students | Year 2 Students | Year 3 Students | Year 4 Students |
|---|---|---|---|---|---|---|---|
| 60 | 70 | 80 | 100 | 20 | 32 | 18 | 25 |
I would like to somehow transpose this table to the following format:
| Year | Grade | Students |
|---|---|---|
| 1 | 60 | 20 |
| 2 | 70 | 32 |
| 3 | 80 | 18 |
| 4 | 100 | 25 |
I created a list of years and initiated a new dataframe with the "year" column. I was thinking of matching the year integer to the column name containing it in the original DF, match and assign the correct value, but got stuck there.