[Python] Keep only rows that have atleast one null

Discussão em 'Python' iniciado por Stack, Setembro 13, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to do basically the opposite of drop_nulls(). I want to keep all rows that have at least one null.

    I want to do something like (but I don't want to list all other columns):

    for (name,) in (
    df.filter(
    pl.col("a").is_null()
    | pl.col("b").is_null()
    | pl.col("c").is_null()
    )
    .select("name")
    .unique()
    .rows()
    ):
    print(
    f"Ignoring `{name}` because it has at least one null",
    file=sys.stderr,
    )
    df = df.drop_nulls()

    Continue reading...

Compartilhe esta Página