1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Replace a row in python polars

Discussão em 'Python' iniciado por Stack, Outubro 1, 2024 às 07:23.

  1. Stack

    Stack Membro Participativo

    I want to replace a row in a polars DataFrame with a single value:

    import numpy as np
    import polars as pl

    df = np.zeros(shape=(4, 4))
    df = pl.DataFrame(df)


    For example I want to replace all values in row at index 1 with 1.0

    ┌──────────┬──────────┬──────────┬──────────┐
    │ column_0 ┆ column_1 ┆ column_2 ┆ column_3 │
    │ --- ┆ --- ┆ --- ┆ --- │
    │ f64 ┆ f64 ┆ f64 ┆ f64 │
    ╞══════════╪══════════╪══════════╪══════════╡
    │ 0.0 ┆ 0.0 ┆ 0.0 ┆ 0.0 │
    │ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1.0 │
    │ 0.0 ┆ 0.0 ┆ 0.0 ┆ 0.0 │
    │ 0.0 ┆ 0.0 ┆ 0.0 ┆ 0.0 │
    └──────────┴──────────┴──────────┴──────────┘


    I was looking for a straightforward solution in the documentation, but I couldn't find one.

    Continue reading...

Compartilhe esta Página