date 2022-08-22 ... 2022-09-05
department CD Other ... Other Total Pages
category ...
Colleges above_100k 59.0 62.0 ... NaN NaN
Exam above_100k NaN NaN ... 8.0 17.0
StudyAbroad above_100k 1.0 1.0 ... 1.0 2.0
Colleges below_100k 77.0 85.0 ... NaN NaN
Exam below_100k NaN NaN ... 26.0 63.0
StudyAbroad below_100k 4.0 5.0 ... 4.0 8.0
Colleges below_10k 28.0 31.0 ... NaN NaN
Exam below_10k NaN NaN ... 9.0 20.0
StudyAbroad below_10k 28.0 24.0 ... 23.0 47.0
Colleges below_1k 0.0 0.0 ... NaN NaN
Exam below_1k NaN NaN ... 0.0 0.0
StudyAbroad below_1k 26.0 24.0 ... 22.0 43.0
Using
pd.pivot_table()you can do this:First we need to make the new 'department'
'Total Pages'and add it to the dataframe.Now we can pivot our dataframe.
Output: