> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# atoti.AggregateProvider

### *final class* atoti.AggregateProvider

An aggregate provider pre-aggregates some measures up to certain levels.

If a step of a query uses a subset of the aggregate provider’s levels and measures, the provider will speed up the query.

An aggregate provider uses additional memory to store the intermediate aggregates.
The more levels and measures are added, the more memory it requires.

### Example

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> df = pd.DataFrame(
...     {
...         "Seller": ["Seller_1", "Seller_1", "Seller_2", "Seller_2"],
...         "ProductId": ["aBk3", "ceJ4", "aBk3", "ceJ4"],
...         "Price": [2.5, 49.99, 3.0, 54.99],
...     }
... )
>>> table = session.read_pandas(df, table_name="Seller")
>>> cube = session.create_cube(table)
>>> l, m = cube.levels, cube.measures
>>> cube.aggregate_providers["Seller"] = tt.AggregateProvider(
...     filter=l["Seller"] == "Seller_1",
...     key="bitmap",
...     levels={l["Seller"]},
...     measures={m["Price.SUM"]},
...     partitioning="modulo4(Seller)",
... )
>>> cube.aggregate_providers
{'Seller': AggregateProvider(filter=l['Seller', 'Seller', 'Seller'] == 'Seller_1', key='bitmap', levels=frozenset({l['Seller', 'Seller', 'Seller']}), measures=frozenset({m['Price.SUM']}), partitioning='modulo4(Seller)')}
```

Pre-aggregating all measures:

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> from dataclasses import replace
>>> cube.aggregate_providers["Seller"] = replace(
...     cube.aggregate_providers["Seller"],
...     measures=None,
... )
>>> cube.aggregate_providers["Seller"]
AggregateProvider(filter=l['Seller', 'Seller', 'Seller'] == 'Seller_1', key='bitmap', levels=frozenset({l['Seller', 'Seller', 'Seller']}), measures=None, partitioning='modulo4(Seller)')
```

#### filter *: AggregateProviderFilterCondition | [None](https://docs.python.org/3/library/constants.html#None)* *= None*

Only compute and provide aggregates matching this condition.

#### key *: AggregateProviderPluginKey* *= 'leaf'*

The key of the provider.

The bitmap is generally faster but also takes more memory.

#### levels *: Annotated\[AbstractSet\[Identifiable\[LevelIdentifier]], Field(min\_length=1), AfterValidator(validate\_hierarchy\_unicity)] | [None](https://docs.python.org/3/library/constants.html#None)* *= None*

The levels to build the provider on.

If a passed level is part of a multilevel hierarchy, all shallower levels will be pre-aggregated too.
If `None`, all eligible levels will be pre-aggregated.

#### measures *: Annotated\[AbstractSet\[Identifiable\[MeasureIdentifier]], Field(min\_length=1)] | [None](https://docs.python.org/3/library/constants.html#None)* *= None*

The measures to build the provider on.

If `None`, all eligible measures will be pre-aggregated.

<Note>
  This collection cannot contain any measure created from a column in a [`partially joined`](./atoti.Table.join#atoti.Table.join) table.
</Note>

#### partitioning *: [str](https://docs.python.org/3/library/stdtypes.html#str) | [None](https://docs.python.org/3/library/constants.html#None)* *= None*

The partitioning of the provider.

Default to the partitioning of the cube’s fact table.
