> For the complete documentation index, see [llms.txt](https://water-strategy.gitbook.io/waterstrategy/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://water-strategy.gitbook.io/waterstrategy/modeling-basics/recorders/base-recorder/aggregator.md).

# Aggregator

## General Description

Utility class for computing aggregate values.

Users are unlikely to use this class directly. Instead *Recorder* sub-classes will use this functionality to aggregate their results across different dimensions (e.g. time, scenarios, etc.). [API Reference](https://pywr.github.io/pywr-docs/master/api/generated/pywr.recorders.Aggregator.html)

## Attributes

<table><thead><tr><th width="158">Name</th><th width="473">Description</th><th>Required</th></tr></thead><tbody><tr><td>func</td><td><p>The aggregation function to use. Can be a string or dict defining aggregation functions, or a callable custom function that performs aggregation.</p><p>When a string it can be one of: “sum”, “min”, “max”, “mean”, “median”, “product”, or “count_nonzero”. These strings map to and cause the aggregator to use the corresponding <em>numpy</em> functions.</p><p>A dict can be provided containing a “func” key, and optional “args” and “kwargs” keys. The value of “func” should be a string corresponding to the aforementioned numpy function names with the additional options of “percentile” and “percentileofscore”. These latter two functions require additional arguments (the percentile and score) to function and must be provided as the values in either the “args” or “kwargs” keys of the dictionary. Please refer to the corresponding numpy (or scipy) function definitions for documentation on these arguments.</p><p>Finally, a callable function can be given. This function must accept either a 1D or 2D numpy array as the first argument, and support the “axis” keyword as integer value that determines which axis over which the function should apply aggregation. The axis keyword is only supplied when a 2D array is given. Therefore,` the callable function should behave in a similar fashion to the numpy functions.</p></td><td>Yes</td></tr><tr><td>func_args</td><td>func_args: list</td><td>Yes</td></tr><tr><td>func_kwargs</td><td>func_kwargs: dict</td><td>Yes</td></tr></tbody></table>

## Example

```json
{
Aggregator("sum")
Aggregator({"func": "percentile", "args": [95],"kwargs": {}})
Aggregator({"func": "percentileofscore", "kwargs": {"score": 0.5, "kind": "rank"}})
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://water-strategy.gitbook.io/waterstrategy/modeling-basics/recorders/base-recorder/aggregator.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
