Skip to content

Clean

matchlab.transformers.clean

Clean derives columns. Add or replace named columns, keep the rest.

Classes:

  • Clean

    Derive columns with DuckDB SQL, without dropping unrelated fields.

Clean

Bases: Transformer


              flowchart TD
              matchlab.transformers.clean.Clean[Clean]
              matchlab.transformers.base.Transformer[Transformer]

                              matchlab.transformers.base.Transformer --> matchlab.transformers.clean.Clean
                


              click matchlab.transformers.clean.Clean href "" "matchlab.transformers.clean.Clean"
              click matchlab.transformers.base.Transformer href "" "matchlab.transformers.base.Transformer"
            

Derive columns with DuckDB SQL, without dropping unrelated fields.

Each entry maps an output column name to a SQL expression over the record step's columns (the source-qualified names, crn_company). An alias that names an existing column replaces it. A new alias is added. Every other column passes through untouched. Dropping is Select's job, not Clean's.

id is not writable. It is the grouping a model matches on, so an alias naming it is refused rather than allowed to displace it.

Methods:

  • apply

    Add or replace the named columns, keeping the rest.

Attributes:

version class-attribute

version: int = 1

cleaning class-attribute instance-attribute

cleaning: dict[str, SQLExpression] = Field(description='Output column name to a DuckDB SQL expression over the step.')

model_config class-attribute instance-attribute

model_config = ConfigDict(extra='forbid', frozen=True)

apply

apply(data: DataFrame) -> DataFrame

Add or replace the named columns, keeping the rest.

Invalid SQL raises at build time, naming the expression.