I would like to visualize the number of required machines in the workshop at a certain time on the graph, and the x-axis - the continuous time axis, and the y-axis - the number of shifts.
In the data table below you will find an example of my data. Here you see the Shift_ID (which are unique) and the start and end times of this shift. During the day, I would like to see how many cars are required in a certain period of time. It can be 5 minutes, a quarter of an hour, half an hour and an hour.
df: Shift_ID Shift_Time_Start Shift_Time_End 0 1 2016-03-22 9:00:00 2016-03-22 9:35:00 1 2 2016-03-22 9:20:00 2016-03-22 10:20:00 2 3 2016-03-22 9:40:00 2016-03-22 10:14:00 3 4 2016-03-22 10:00:00 2016-03-22 10:31:00
In this example, in the quarter 9: 30-9: 45 I would need 3 cars to be able to do each shift at this particular time. The desired result will look something like this:
df2: Interval Count 0 2016-03-22 9:00:00 - 2016-03-22 9:15:00 1 1 2016-03-22 9:15:00 - 2016-03-22 9:30:00 2 2 2016-03-22 9:30:00 - 2016-03-22 9:45:00 3 3 2016-03-22 9:45:00 - 2016-03-22 10:00:00 2 4 2016-03-22 10:00:00 - 2016-03-22 10:15:00 2 5 2016-03-22 10:15:00 - 2016-03-22 10:30:00 2 6 2016-03-22 10:30:00 - 2016-03-22 10:45:00 1
With this data frame, I could round it to the very bottom of the interval, and then build it in a graph.
I went in cycles on how to "see" whether the shift is within several intervals. Do you have any ideas how to handle this?
NB: all date and time values, of course, are of type datetime
EDIT after solving MaxU and knightofni
I used MaxU code to build both of your codes. It seems that they are doing well with 15min, but please take a look at the results with 5 minutes:
MaxU:

knightofni:

EDIT 2 April 4, 2015
source share