I have a simple DataFrame like this:
timestamp | Power |
---|---|
29/08/2021 02:30:16 | 155 |
29/08/2021 02:45:19 | 151 |
29/08/2021 03:00:14 | 155 |
29/08/2021 03:30:12 | 152 |
29/08/2021 04:00:12 | 149 |
29/08/2021 04:15:09 | 152 |
29/08/2021 04:30:16 | 153 |
29/08/2021 04:45:09 | 211 |
29/08/2021 05:30:19 | 77 |
So these data should be measured every 15 minutes, but for some reason some measurements have been skipped. I want to add the missing timestamps followed by a "NaN" when the measurement is skipped. I know that this can be done by the function "resample" but it's important to use it only when needed. So what I need is to add a condition to that function: I want to resample only between those rows that are (for example) more than 16 minutes distant from each other. In this way, when I don't need to resample, the timestamps will still be the original ones, and this is very important for my work. So what I want to obtain is, more or less:
timestamp | Power |
---|---|
29/08/2021 02:30:16 | 155 |
29/08/2021 02:45:19 | 151 |
29/08/2021 03:00:14 | 155 |
29/08/2021 03:15:00 | NaN |
29/08/2021 03:30:12 | 152 |
29/08/2021 03:45:00 | NaN |
29/08/2021 04:00:12 | 149 |
29/08/2021 04:15:09 | 152 |
29/08/2021 04:30:16 | 153 |
29/08/2021 04:45:09 | 211 |
29/08/2021 05:00:00 | NaN |
29/08/2021 05:15:00 | NaN |
29/08/2021 05:30:19 | 77 |