I have a dataframe with start and end time for each unique rating ID.
d={'ID':['01','02','03','04','05','06'],'Hour Start':[5,9,13,15,20,23],'Hour End':[6,9,15,19,0,2]}
df=pd.DataFrame(data=d)
My goal is to aggregate how many ratings were active hourly for the whole dataset. For example, ID:01 started during 5 am and 6 am. Then 5 am and 6 am should both add 1 count each.
But for ID:06, the rating started in 11 pm and ended next day at 2 am. Hence each hour should add 1 count each hour from 11 pm to 2 am.
I want to output a table for hourly summary like below.
I have been thinking a while for a solution.
Any help would be very appreciated ! Thank you !
