suppose there are many workers for a business, and all of them work different amount of hours that start and end at different hours of the day.
each day, and you are given a list of each workers' start and end times.
what is the fastest and most efficient way to create a dataframe column that contains the number of workers that will be working at each hour for the day?
df=pd.Dataframe([9,10,11,12,13,14,15,16,17],columns=['business_hrs'])
df['ppl_working']=0
start_times=[8,9,13,12,10]
end_times=[12,13,17,16,13]
this is the first thing i thought of
for s,e in zip(start_times,end_times):
df.loc[(df['business_hrs']>=s) & (df['business_hrs']<=e),'ppl_working']+=1
intuition tells me there is a much more efficient way to do this, without having to do as much iteration, and would make a difference if there are for example millions of workers
