Skip to content

mecfs_bio.build_system.task.pipes.str_replace_pipe

Classes:

StrReplacePipe

Bases: DataProcessingPipe

Methods:

Attributes:

new_column_name instance-attribute

new_column_name: str

replace_what instance-attribute

replace_what: str

replace_with instance-attribute

replace_with: str

target_column instance-attribute

target_column: str

process

process(x: LazyFrame) -> narwhals.LazyFrame
Source code in mecfs_bio/build_system/task/pipes/str_replace_pipe.py
def process(self, x: narwhals.LazyFrame) -> narwhals.LazyFrame:
    return x.with_columns(
        narwhals.col(self.target_column)
        .str.replace_all(self.replace_what, self.replace_with)
        .alias(self.new_column_name)
    )