---
type: concept
x-llmwiki:
  schemaVersion: "0.1"
  contentHash: 937bac27e0b2a1916383bc101459d1856d141f92b95250a1a93ade5fa585d10c
  pageDirectory: concepts
  sources:
    - data-preparation-for-forecasting-databricks-on-aws.md
  confidence: 1
  provenanceState: extracted
  freshnessStatus: unverified
  aliases:
    - time-series-aggregation-for-forecasting
    - TSAFF
  citations:
    - file: data-preparation-for-forecasting-databricks-on-aws.md
title: Time Series Aggregation for Forecasting
description: The strategy used by Databricks AutoML to handle multiple values per timestamp in a time series, defaulting to averaging but configurable to summation via notebook source code edits.
tags:
  - forecasting
  - data-preparation
  - aggregation
  - time-series
timestamp: "2026-06-19T14:43:44.543Z"
---

# Time Series Aggregation for Forecasting

**Time Series Aggregation for Forecasting** refers to the process of consolidating multiple data points that share the same timestamp within a time series into a single representative value before training a forecasting model. This is a necessary preprocessing step when the source data contains multiple observations recorded at the same time point for the same time series. ^[data-preparation-for-forecasting-databricks-on-aws.md]

## Overview

When preparing data for forecasting tasks, it is common to encounter datasets where multiple values exist for a single timestamp within a time series. For example, a sensor might record multiple readings in the same minute, or sales data might have multiple transactions with the same timestamp. Before training can proceed, these duplicate-timestamp values must be aggregated into a single value. ^[data-preparation-for-forecasting-databricks-on-aws.md]

## Default Behavior

By default, [AutoML for Forecasting](/concepts/auto-arima-for-forecasting.md) uses the **average** of all values at a given timestamp when performing time series aggregation. This is the standard behavior for handling multiple values per timestamp in forecasting training. ^[data-preparation-for-forecasting-databricks-on-aws.md]

## Customizing the Aggregation Method

You can change the aggregation method from the default average to other operations. To use **sum** instead of average, edit the source code notebook generated by the trial runs. In the **Aggregate data by …** cell, modify the aggregation function: ^[data-preparation-for-forecasting-databricks-on-aws.md]

```python
# Change from default average to sum
group_cols = [time_col] + id_cols
df_aggregation = df_loaded \
  .groupby(group_cols) \
  .agg(y=(target_col, "sum")) \
  .reset_index() \
  .rename(columns={ time_col: "ds" })
```

The key change is replacing `.agg(y=(target_col, "avg"))` with `.agg(y=(target_col, "sum"))`. ^[data-preparation-for-forecasting-databricks-on-aws.md]

## How Aggregation Works

The aggregation process groups data by the time column and any identifier columns, then applies the specified aggregation function to the target column. This ensures each timestamp has a single, representative value for training. This step is part of the data preparation pipeline that AutoML generates for each forecasting trial run. ^[data-preparation-for-forecasting-databricks-on-aws.md]

## When to Use Different Aggregation Methods

| Aggregation | Use Case |
|---|---|
| **Average** | Default behavior. Best for continuous measurements like temperature, sensor readings, or rates |
| **Sum** | Best for count data or totals, such as total sales per day or total events per hour |

##

# Citations

1. [data-preparation-for-forecasting-databricks-on-aws.md](/references/data-preparation-for-forecasting-databricks-on-aws-d40acbea.md)
