Group
matchlab.transformers.group
¶
Group changes granularity. Collapse each id to one row.
Classes:
-
Group–Collapse each
idto a single row, combining columns with aggregate SQL.
Group
¶
Bases: Transformer
flowchart TD
matchlab.transformers.group.Group[Group]
matchlab.transformers.base.Transformer[Transformer]
matchlab.transformers.base.Transformer --> matchlab.transformers.group.Group
click matchlab.transformers.group.Group href "" "matchlab.transformers.group.Group"
click matchlab.transformers.base.Transformer href "" "matchlab.transformers.base.Transformer"
Collapse each id to a single row, combining columns with aggregate SQL.
Reading several records per entity (through a resolver) gives a model more evidence,
but a comparison needs one row. Group says how each column combines. id is the
grouping key, and every named expression is a DuckDB aggregate, for example
any_value(crn_company) where records agree or list(distinct crn_town) where they
don't. Only id and the named aggregates survive, since grouping has to decide how
every column collapses.
Methods:
-
apply–Collapse each
idto one row using the aggregate expressions.
Attributes:
-
version(int) – -
aggregates(dict[str, SQLExpression]) – -
model_config–
aggregates
class-attribute
instance-attribute
¶
aggregates: dict[str, SQLExpression] = Field(description='Output column name to a DuckDB aggregate expression.')
model_config
class-attribute
instance-attribute
¶
apply
¶
Collapse each id to one row using the aggregate expressions.
A non-aggregate expression raises DuckDB's own error, naming the column.