Skip to content

mecfs_bio.build_system.task.pipes.replace_pipe

Classes:

ReplaceStrictPipe

Bases: DataProcessingPipe

Methods:

Attributes:

default class-attribute instance-attribute

default: Expr | None = None

new_column_name instance-attribute

new_column_name: str

replace_mapping instance-attribute

replace_mapping: Mapping

target_column instance-attribute

target_column: str

process

process(x: LazyFrame) -> narwhals.LazyFrame
Source code in mecfs_bio/build_system/task/pipes/replace_pipe.py
def process(self, x: narwhals.LazyFrame) -> narwhals.LazyFrame:
    return x.with_columns(
        narwhals.col(self.target_column)
        .replace_strict(self.replace_mapping, default=self.default)
        .alias(self.new_column_name)
    )