Skip to content

mecfs_bio.build_system.task.pipes.pivot_pipe

Classes:

  • PivotPipe

    Transform a dataframe from long to wide format.

PivotPipe

Bases: DataProcessingPipe

Transform a dataframe from long to wide format.

Methods:

Attributes:

index instance-attribute

index: str | list[str] | None

on instance-attribute

on: str | list[str]

values instance-attribute

values: str | list[str] | None

process

process(x: LazyFrame) -> narwhals.LazyFrame
Source code in mecfs_bio/build_system/task/pipes/pivot_pipe.py
def process(self, x: narwhals.LazyFrame) -> narwhals.LazyFrame:
    return (
        x.collect()
        .pivot(
            on=self.on,
            index=self.index,
            values=self.values,
        )
        .lazy()
    )