Trend Resampling
Trend resampling is the process of transforming time-series data from one interval to another by aggregating values into larger time buckets. This is commonly used to reduce data resolution for visualization, reporting, or storage optimization.
Intervals
Resampling transforms data from one fixed interval to another. The original data must be uniformly sampled (e.g., every 15 minutes), and resampling groups this data into larger time buckets. If the selected interval matches the original, the data is returned unchanged.
Supported resample intervals:
auto
(automatically selects the best interval based on time span)15min
30min
1hr
1day
1mo
Aggregation Functions
When resampling, multiple values from a smaller interval are combined into a single value for a larger interval. This is done using aggregation functions, which determine how the values within each group are reduced. Different types of data require different strategies:
- Use
mean
for smoothing or averaging sensor noise. - Use
sum
for totals over time, like energy or flow. - Use
min
/max
to track range extremes. - Use
diff
to measure change across the interval.
For most aggregation functions, the result is placed at the starting
timestamp of the interval as seen in examples below. For
diff
the result is placed at the ending timestamp, since it
represents the net change across the interval.
mean
The arithmetic average of all non-null values in the group.
Use case: Normalize noisy signals, reduce data size while preserving trends.
Example:
Timestamp | Values | mean |
---|---|---|
00:00 | 2.0 | 5.0 |
00:15 | 4.0 | |
00:30 | 6.0 | |
00:45 | 8.0 |
sum
The sum of all non-null values in the group.
Use case: Calculate total energy use, flow, or any cumulative metric over time.
Example:
Timestamp | Values | sum |
---|---|---|
00:00 | 2.0 | 20.0 |
00:15 | 4.0 | |
00:30 | 6.0 | |
00:45 | 8.0 |
min
The smallest non-null value in the group.
Use case: Track minimum temperatures, loads, or pressure within each interval.
Example:
Timestamp | Values | min |
---|---|---|
00:00 | 6.0 | 1.5 |
00:15 | 3.0 | |
00:30 | 1.5 | |
00:45 | 8.0 |
max
The largest non-null value in the group.
Use case: Identify peak values, such as maximum demand or temperature.
Example:
Timestamp | Values | max |
---|---|---|
00:00 | 6.0 | 8.0 |
00:15 | 3.0 | |
00:30 | 1.5 | |
00:45 | 8.0 |
diff
Calculates the difference between the last and first non-null values in the group.
Use case: Compute net change over time, such as delta kWh.
Example:
Timestamp | Values | min |
---|---|---|
00:00 | 2.0 | null |
00:15 | 4.0 | |
00:30 | 6.5 | |
00:45 | 8.0 | |
01:00 | 10.0 | 8.0 |
NA Handling
Real-world data often includes missing values (na
,
meaning “not available”). During resampling, these gaps are handled
consistently to ensure meaningful results while avoiding misleading
calculations. The rules below define how na
values are
treated for each aggregation group.
- If all values in a group are
na
, the result isna
. - If some values are
na
, they are ignored in aggregation. - For
diff
, the first and last non-null values are used. If there are not at least two non-null values, the result isna
.