Function sumHorizontal

  • Sum all values horizontally across columns.

    Parameters

    • exprs: ExprOrString | ExprOrString[]

    Returns pl.Expr

     >>> const df = pl.DataFrame(
    ... {
    ... "a": [1, 8, 3],
    ... "b": [4, 5, null],
    ... "c": ["x", "y", "z"],
    ... }
    ... )
    >>> df.withColumns(pl.sumHorizontal(pl.col("a"), ol.col("b")))
    shape: (3, 4)
    ┌─────┬──────┬─────┬──────┐
    abcsum
    │ --- ┆ --- ┆ --- ┆ --- │
    i64i64stri64
    ╞═════╪══════╪═════╪══════╡
    14x5
    85y13
    3nullznull
    └─────┴──────┴─────┴──────┘