I have a dataframe where I have a column having the group no. Under each group there are multiple processes associated which has a specific start and end time.
It looks like the following:
Group | Process | StartTime | EndTime |
-----------------------------------------------------------------
1 | A | 2023-01-01 10:09:18 | 2023-01-01 11:19:28 |
1 | B | 2023-01-01 11:29:01 | 2023-01-01 19:29:00 |
1 | C | 2023-01-01 19:56:11 | 2023-01-02 01:09:10 |
2 | A | 2023-02-14 23:54:11 | 2023-02-15 04:01:14 |
2 | B | 2023-02-14 05:56:11 | 2023-02-14 09:00:20 |
2 | D | 2023-02-14 10:16:01 | 2023-02-14 21:06:30 |
All I want to do is for each group I want to resample the dataframe with a frequency of 1 minute with the start and end time.
For ex. for Group 1 for Process A, I will have rows starting from 01-01-2023 10:09 to 11:20, sample at a frequency of 1min, which is df.resample('1T')
Group | Process | Sample Timestamp | StartTime | EndTime |
--------------------------------------------------------------------------------------
1 | A | 2023-01-01 10:09:00 | 2023-01-01 10:09:18 | 2023-01-01 11:19:28|
1 | A | 2023-01-01 10:10:00 | 2023-01-01 10:09:18 | 2023-01-01 11:19:28|
1 | A | 2023-01-01 10:11:00 | 2023-01-01 10:09:18 | 2023-01-01 11:19:28|
.... | ... | ... | ... | ... |
1 | A | 2023-01-01 11:18:00 | 2023-01-01 10:09:18 | 2023-01-01 11:19:28|
1 | A | 2023-01-01 11:19:00 | 2023-01-01 10:09:18 | 2023-01-01 11:19:28|
1 | B | 2023-01-01 11:29:00 | 2023-01-01 11:29:01 | 2023-01-01 19:29:00|
1 | B | 2023-01-01 11:30:00 | 2023-01-01 11:29:01 | 2023-01-01 19:29:00|
.... | ... | ... | ... | ... |
1 | B | 2023-01-01 19:28:00 | 2023-01-01 11:29:01 | 2023-01-01 19:29:00|
1 | B | 2023-01-01 19:29:00 | 2023-01-01 11:29:01 | 2023-01-01 19:29:00|
< same for Process C and other Groups as well>
As a reference I tried this piece of code over here: Reference Code
But unfortunately, I am unable to implement it by each group.
Any help is appreciated.