Explode
matchlab.transformers.explode
¶
Explode changes granularity. Cross-join each id's columns to every combination.
Classes:
-
Explode–Give every combination of each
id's non-null column values its own row.
Explode
¶
Bases: Transformer
flowchart TD
matchlab.transformers.explode.Explode[Explode]
matchlab.transformers.base.Transformer[Transformer]
matchlab.transformers.base.Transformer --> matchlab.transformers.explode.Explode
click matchlab.transformers.explode.Explode href "" "matchlab.transformers.explode.Explode"
click matchlab.transformers.base.Transformer href "" "matchlab.transformers.base.Transformer"
Give every combination of each id's non-null column values its own row.
Group collapses each id to one row. Explode goes the other way, giving the
true cross product a list aggregate can't express. Every non-null value in one
column pairs with every non-null value in every other column, for the same id.
Values are deduplicated per column first, so a value repeated across records
counts once. A column that is all null for one id still keeps that row, with
null there, instead of dropping it.
An id with several populated columns can generate many rows fast, so
max_combinations caps it and raises, naming the id, rather than silently
building an enormous table.
Methods:
-
apply–Cross-join each
id's columns to every combination of their values.
Attributes:
-
version(int) – -
max_combinations(int) – -
model_config–
max_combinations
class-attribute
instance-attribute
¶
max_combinations: int = Field(default=100, description='Reject a group whose cross product would exceed this many rows.')
model_config
class-attribute
instance-attribute
¶
apply
¶
Cross-join each id's columns to every combination of their values.