Suppose I have a list of stores (e.g. Walmart, Costco, etc.), as well as: 1. data on their open hours, 2. data on each customer that enters the store, and 3. data on each customer that pays and leaves the store. (For 2 and 3, customers can wait outside of the store before it opens and leave after it closes, respectively; this is not precluded in the data). How might one go about calculating the queue (i.e. the number of customers in the store) at every hour mark during the open hours?
Originally, I thought I might look at each data point and find out the customers at this specific hour mark (this isn't too tricky). However, it does not account for the other hours that the store is open. In other words, saying that there are 4 people in the store at 3 p.m. is insufficient, as it does not describe the hours of 4, 5, 6 p.m., etc., even if the number of people remains the same. Simply put, I'm not sure how to find the number of customers during each hour of store open hours. Additionally, I would assume that I would need to create a different dataframe to store this information, as its size would not match up with the data set that I currently have.
I've pasted some sample data below:
input str15 store_name double(open close customer_arrival customer_leave)
"Walmart" 15may2020 13:00:00 15may2020 22:00:00 15may2020 20:40:00 15may2020 22:51:00
"Costco" 15may2020 19:00:00 16may2020 4:00:00 15may2020 21:31:00 16may2020 1:10:00
"Costco" 15may2020 19:00:00 16may2020 4:00:00 16may2020 1:32:00 16may2020 7:40:00
"Costco" 15may2020 19:00:00 16may2020 4:00:00 15may2020 20:52:00 16may2020 00:42:00
"Target" 16may2020 03:00:00 16may2020 12:00:00 16may2020 02:13:00 16may2020 04:47:00
"Target" 16may2020 03:00:00 16may2020 12:00:00 16may2020 07:28:00 16may2020 13:55:00
For example, for Walmart on the given day, there were no individuals in the store from 13:00 to 20:40, which means that the time buckets for 13:00 to 20:00 would indicate 0. Then for the buckets 21:00 and 22:00, there would be 1 person in queue, and then none again at 23:00.
Any suggestions as to how to proceed would be sincerely appreciated. If I've omitted any details/if I could be more clear, please let me know. Cheers.