I've got a dataframe with power profiles. The dataframe shows start and endtime and consumed power during a transaction. It looks something like this:
TransactionId | StartTime | EndTime | Power |
---|---|---|---|
xyza123 | 2018.01.01 07:07:34 | 2018.01.01 07:34:08 | 70 |
hjker383 | 2018.01.01 10:21:00 | 2018.01.01 11:40:08 | 23 |
My Goal is to assign a new Start- and EndTime which are set at 15 min values. Like so:
TransactionId | StartTime | New Starttime | EndTime | New EndTime | Power |
---|---|---|---|---|---|
xyza123 | 2018.01.01 07:07:34 | 2018.01.01 07:00:00 | 2018.01.01 07:34:08 | 2018.01.01 07:30:00 | 70 |
hjker383 | 2018.01.01 10:21:00 | 2018.01.01 10:30:00 | 2018.01.01 11:40:08 | 2018.01.01 11:45:00 | 23 |
The old Timestamps can be deleted afterwards. However I don't want to aggregate them. So I guess
df.groupby(pd.Grouper(key="StartTime", freq="15min")).sum()
or
df.groupby(pd.Grouper(key="StartEndtime", freq="15min")).mean()
etc. is not an option.
Another idea I had was creating a dataframe with values between 2018.01.01 00:00:00
and 2018.01.01 23:45:00
. However I am not sure how to iterate true the two dataframes, to achieve my goal and if iteration true dataframes is a good idea in the first place.