Home > Software engineering >  Python / Pandas - How can I group a DF by two columns
Python / Pandas - How can I group a DF by two columns

Time:04-04

I got a dataset that is built ike this:

hour weekday
12   2
14   1
12   2

and so on. I want to display in a heatmap per weekday when the dataframe had most action (which is the sum of all events that happened on that weekday during that hour)

I tried wo work with groupBy

hm = df.groupby(['hour']).sum()

which shows me all events for the hours, but does not split the events across the weekdays

How can I keep the list so I have the weekdays as an x-axis and on the y-axis the sum of the hours on that weekday?

thanks for your help!

CodePudding user response:

The output you expect is unclear, but I imagine you could be looking for enter image description here

  • Related