[Python] Create a Polars Dataframe by appending multiple row at a time

Discussão em 'Python' iniciado por Stack, Maio 20, 2025.

  1. Stack

    Stack Membro Participativo

    How can I make DataFrame and then more rows one at a time?

    import polars as pl


    df_polars = pl.DataFrame({
    'abc': [],
    'def': [],
    'ghi': []
    })


    value_to_set = 10.0
    df_polars = df_polars.extend([
    pl.lit(None).alias('abc'),
    pl.lit(value_to_set).alias('def'),
    pl.lit(None).alias('ghi')
    ])


    print(df_polars)


    It only works for one field at a time. What is a more efficient approach to add several rows to my data-frame?

    Continue reading...

Compartilhe esta Página