<!-- Source: https://docs.squirro.com/en/latest/api/squirro.lib.nlp.steps.filters.AggregateFilter.html -->
# AggregateFilter

**`class AggregateFilter(config)`**

Bases: [`Filter`](squirro.lib.nlp.steps.filters.Filter.md#squirro.lib.nlp.steps.filters.Filter)

The aggregate [`Filter`](squirro.lib.nlp.steps.filters.Filter.md#squirro.lib.nlp.steps.filters.Filter) concatenates / sums up the field values of the aggregated_fields grouped by the value of the aggregating_field

**Input** - the aggregated_fields need to be of type [`int`](https://docs.python.org/3.11/library/functions.html#int), [`float`](https://docs.python.org/3.11/library/functions.html#float) or [`list`](https://docs.python.org/3.11/library/stdtypes.html#list)

**Output** - the output field is filled with data of type [`int`](https://docs.python.org/3.11/library/functions.html#int), [`float`](https://docs.python.org/3.11/library/functions.html#float) or [`list`](https://docs.python.org/3.11/library/stdtypes.html#list) according to the type of the aggregated_fields

Parameters

- `type` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – aggregate
- `aggregated_fields` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)) – Fields to aggregate
- `aggregating_field` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – Field to aggregate into
- `output_field` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``None`) – Field to store the aggregation (defaults to aggregating_field)
- `use_separate_docs` ([`bool`](https://docs.python.org/3.11/library/functions.html#bool)`, ``True`) – Whether or not to use a separate doc for each aggregating value

**Example**

```json
{
        "step": "filter",
        "type": "aggregate",
        "output_field": "out",
        "aggregated_fields": ["b", "c"],
        "aggregating_field": "a",
    }
```

Methods SummaryMethods Documentation

**`process(docs)`**

Process a set of documents

Parameters

`docs` (`generator``(`[`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)`)`) – Generator of documents

Returns

Generator of processed documents

Return type

generator([Document](../technical/libnlp/base.md#squirro.lib.nlp.document.Document))

**`train(docs)`**

Train on a step of a set of documents

Parameters

`docs` (`generator``(`[`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)`)`) – Generator of documents

Returns

Generator of processed documents

Return type

generator([Document](../technical/libnlp/base.md#squirro.lib.nlp.document.Document))
