I'm trying to see if there's a way to use Pandas to do the following calculation:
I have a table which has Event numbers followed by their respective start and end datetimes.
Event Number Start End
1 6/1/2020 13:00 6/1/2020 13:30
2 6/1/2020 17:45 6/1/2020 19:15
3 6/4/2020 8:00 6/4/2020 9:10
4 6/7/2020 11:00 6/7/2020 11:50
And separately I have another table which has the raw time indexed data for each sensor
Datetime Sensor 1 Sensor 2 Sensor 3
6/1/2020 0:00 80 4 0
6/1/2020 0:01 80 5 0
6/1/2020 0:02 69 9 1
6/1/2020 0:03 72 8 0
6/1/2020 0:04 60 9 0
6/1/2020 0:05 76 3 0
6/1/2020 0:06 62 8 1
6/1/2020 0:07 80 8 0
6/1/2020 0:08 64 7 1
Is there a way that I can run down that original table and crop this one based on the START and END timestamps?
What I'm trying the final table to look like is something that includes the
- Open
- Close
- Min
- Max
- Mean
of all sensors between those dates.
I've tried without much luck to use a for loop but it takes very long (+3M lines of raw data).
Is there any way to do this with pandas?
Thanks to all in advance
EDIT 1: Added what I had in mind as an output for clarification:
Event Type Sensor 1 Sensor 2 Sensor 3
1 Open 60 5 1
1 Close 69 8 0
1 Max 78 8 1
1 Min 59 4 0
1 Mean 69 8 0.333
2 Open 77 4 0
2 Close 73 6 1
2 Max 77 6 1
2 Min 68 4 0
2 Mean 74 6 0.667
3 Open 63 4 1
3 Close 71 7 1
3 Max 70 8 1
3 Min 63 3 0
3 Mean 65 4 1