I have a timeseries with a 5 minute resolution and I would like to aggregate (average) all values within 30 minutes intervals for each category (X/Y/Z) variable.
I have found many threads here on SO but none of them aggregates half-hourly and I don't have an idea how to combine the half-hourly aggregation with a second column. Furthermore, I would appreciate it if there would be a data.table solution, because of the superior performance. The original tables are several million rows long with 1000s of categories.
My data looks like this:
+---------------------+------+------------+
| Timestamp | DUID | Meter_Prod |
+---------------------+------+------------+
| 2018-03-01 00:00:00 | X | 1 |
| 2018-03-01 00:00:00 | Y | 2 |
| 2018-03-01 00:00:00 | Z | 3 |
| 2018-03-01 00:05:00 | X | 1 |
| 2018-03-01 00:05:00 | Y | 2 |
| 2018-03-01 00:05:00 | Z | 3 |
| ... | | |
| 2018-03-01 00:55:00 | X | 1 |
| 2018-03-01 00:55:00 | Y | 2 |
| 2018-03-01 00:55:00 | Z | 3 |
+---------------------+------+------------+
I would like to have this
+---------------------+------+--------------------+
| Timestamp | DUID | Meter_Prod_Average |
+---------------------+------+--------------------+
| 2018-03-01 00:00:00 | X | 1 |
| 2018-03-01 00:00:00 | Y | 2 |
| 2018-03-01 00:00:00 | Z | 3 |
| 2018-03-01 00:30:00 | X | 1 |
| 2018-03-01 00:30:00 | Y | 2 |
| 2018-03-01 00:30:00 | Z | 3 |
+---------------------+------+--------------------+
An example data frame is uploaded here: https://pastebin.com/4bESGTKH