Skip to main content
The Regroup Entities step removes an entity and regroups the data by the ones that remain, using a formula you choose to aggregate. It is the equivalent of GROUP BY in SQL or groupby in pandas.

Why entities need care

Entity columns are the columns required to uniquely identify a row. Because of that, a combination of entity values can never repeat — which makes removing or changing entities a delicate operation that can corrupt the data if done carelessly. Say you have a dataset with Date and Country as entities, the most common combination in Alphacast. You will have many rows for the same date, one per country. You cannot simply drop the Country column, because dates would then repeat and entity combinations must be unique.
A dataset with Date and Country as entities
Regrouping is how you resolve this.

How to regroup

1

Create a pipeline and select the source

Start from a Fetch Dataset step.
2

Add the Regroup Entities step

3

Choose which entities to drop

Deselect the entities you want to remove.
4

Choose the aggregation per column

Decide how rows that now share the same entity values should be combined — the Date, in the example above.The aggregation is set per column, so different columns can be combined differently in the same step. The right choice depends entirely on what each column represents.
Weighted aggregations are the right choice when combining rates or ratios across entities — a weighted mean of inflation across countries needs a population or GDP weight column, since a plain mean would treat every country equally.
The result keeps every entity except the ones you excluded, and has fewer rows than the original because rows sharing entity values are collapsed together.
Result of regrouping entities
This step uses the fixed list of aggregations above, not the formula editor. To compute a value that isn’t in the list, add a Calculate Variable step before or after regrouping.

Next steps

Calculate variable

Compute values the fixed aggregations don’t cover.

Change frequency

Aggregate along the time dimension instead.