Home > Software design >  Heatmap to visualize percentage of values
Heatmap to visualize percentage of values

Time:01-24

I am looking for visualizing the results below, got by grouping my data by columns , using a heatmap.

Data

    Classroom   Subject    Student
0   A   Mathematics         A.B.
1   B   Computer Science    G.M.
2   A   Computer Science    J.K.
3   B   Literature          S.R.
4   B   Computer Science    A.M.
5   A   Literature          S.R.
6   B   Mathematics         S.E.
7   C   Literature          S.T.
8   C   Mathematics         R.B.
9   A   Mathematics         B.K.

After grouping df.groupby(["Classroom", "Subject"]).size(), I have

Classroom     Subject                    
A             Mathematics                 226
              Literature                  12
              Computer Science            122
B             Mathematics                 1
              Literature                  14
              Computer Science            19
              History                     22
              Geography                   238
C             Mathematics                 5
              Literature                  15
              

Seaborn would be probably the nicest solution for creating a heatmap and showing the percentage of the values (.sum()/len(df))*100), if I am right) based on what I have found on the Web. This solution sns.heatmap from pivot_table

  •  Tags:  
  • Related