I have a dataframe df
hour calls received appointment
6:48 4 2 2
4:02 21 3 2
12:52 31 7 4
2:14 32 5 2
6:45 13 3 2
The hour column is string
I want to calculate the sum and group by the hour in the format like 1-2,2-3.
My approach would be:
df[['hour','calls','received','appointment']].groupby('hour').sum()
Also, I would like to check for every hour, if data is not present for any hour, fill it by zero.
I want the output as :
hour calls received appointment
0-1 0 0 0
1-2 0 0 0
2-3 32 5 2
3-4 0 0 0
4-5 21 3 2
5-6 0 0 0
6-7 17 5 4
...