[Python] Python polars -- how to apply function across multiple cols

Discussão em 'Python' iniciado por Stack, Fevereiro 19, 2025.

  1. Stack

    Stack Membro Participativo

    How to extend this

    df = df.select(
    pl.col("x1").map_batches(custom_function).alias("new_x1")
    )


    to something like

    df = df.select(
    pl.col("x1","x2").map_batches(custom_function).alias("new_x1", "new_x2")
    )


    Or the way to go is doing it one by one

    df = df.select(
    pl.col("x1").map_batches(custom_function).alias("new_x1")
    pl.col("x2").map_batches(custom_function).alias("new_x2")
    )

    Continue reading...

Compartilhe esta Página