I am trying to do the following using Pandas (Python).
I have a dataframe with the following columns:
Building, Door_Color, Door_Time_Open, Door_Time_Close, Opening_Width
I am trying to group the data by date and time in such a way that for each second I would count the number of doors open and the sum of the width_of_opening.
for example:
Data:
Building, Door_Color, Door_Time_Open, Door_Time_Close, Opening_Width
A , Red , 2000-01-01 00:00:00, 2000-01-01 00:00:05, 10
A , Red , 2000-01-01 00:00:02, 2000-01-01 00:00:04, 5
Result:
Date, Building, Door_Color, Door_Count, Sum_Opening_Width
2000-01-01 00:00:00, A, Red, 1 , 10
2000-01-01 00:00:01, A, Red, 1 , 10
2000-01-01 00:00:02, A, Red, 2 , 15
2000-01-01 00:00:03, A, Red, 2 , 15
2000-01-01 00:00:04, A, Red, 2 , 15
2000-01-01 00:00:05, A, Red, 1 , 10
2000-01-01 00:00:06, A, Red, 0 , 0
I know how to do a regular group by multiple columns and aggregate different columns separately but I haven't got a clue how to get the machine to check if the date we are grouping by falls between the two dates in the data.
Any help would be much appreciated!
edit1: data is a little big, about 6 million rows.