nodejs-polars
    Preparing search index...

    Function struct

    • Parameters

      • exprs: pl.Series<any, string>[]
        >pl.DataFrame(
        ... {
        ... "int": [1, 2],
        ... "str": ["a", "b"],
        ... "bool": [True, None],
        ... "list": [[1, 2], [3]],
        ... }
        ... ).select([pl.struct(pl.all()).alias("my_struct")])
        shape: (2, 1)
        ┌───────────────────────┐
        my_struct
        │ --- │
        struct{int, ... list} │
        ╞═══════════════════════╡
        │ {1,"a",true,[1, 2]} │
        ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
        │ {2,"b",null,[3]} │
        └───────────────────────┘

        // Only collect specific columns as a struct:
        >df = pl.DataFrame({
        ... "a": [1, 2, 3, 4],
        ... "b": ["one", "two", "three", "four"],
        ... "c": [9, 8, 7, 6]
        ... })
        >df.withColumn(pl.struct(pl.col(["a", "b"])).alias("a_and_b"))
        shape: (4, 4)
        ┌─────┬───────┬─────┬───────────────────────────────┐
        abca_and_b
        │ --- ┆ --- ┆ --- ┆ --- │
        i64stri64struct[2]{'a': i64, 'b': str} │
        ╞═════╪═══════╪═════╪═══════════════════════════════╡
        1one9 ┆ {1,"one"} │
        ├╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
        2two8 ┆ {2,"two"} │
        ├╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
        3three7 ┆ {3,"three"} │
        ├╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
        4four6 ┆ {4,"four"} │
        └─────┴───────┴─────┴───────────────────────────────┘

      Returns pl.Series

    • Parameters

      • exprs: ExprOrString | ExprOrString[]
        >pl.DataFrame(
        ... {
        ... "int": [1, 2],
        ... "str": ["a", "b"],
        ... "bool": [True, None],
        ... "list": [[1, 2], [3]],
        ... }
        ... ).select([pl.struct(pl.all()).alias("my_struct")])
        shape: (2, 1)
        ┌───────────────────────┐
        my_struct
        │ --- │
        struct{int, ... list} │
        ╞═══════════════════════╡
        │ {1,"a",true,[1, 2]} │
        ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
        │ {2,"b",null,[3]} │
        └───────────────────────┘

        // Only collect specific columns as a struct:
        >df = pl.DataFrame({
        ... "a": [1, 2, 3, 4],
        ... "b": ["one", "two", "three", "four"],
        ... "c": [9, 8, 7, 6]
        ... })
        >df.withColumn(pl.struct(pl.col(["a", "b"])).alias("a_and_b"))
        shape: (4, 4)
        ┌─────┬───────┬─────┬───────────────────────────────┐
        abca_and_b
        │ --- ┆ --- ┆ --- ┆ --- │
        i64stri64struct[2]{'a': i64, 'b': str} │
        ╞═════╪═══════╪═════╪═══════════════════════════════╡
        1one9 ┆ {1,"one"} │
        ├╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
        2two8 ┆ {2,"two"} │
        ├╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
        3three7 ┆ {3,"three"} │
        ├╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
        4four6 ┆ {4,"four"} │
        └─────┴───────┴─────┴───────────────────────────────┘

      Returns pl.Expr