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

[Python] How to exclude the include_file_paths column from lazyframe without streaming

Discussão em 'Python' iniciado por Stack, Outubro 7, 2024 às 09:32.

  1. Stack

    Stack Membro Participativo

    I cannot exclude the column when streaming=False

    import tempfile
    import polars as pl

    with tempfile.NamedTemporaryFile() as f:
    pl.read_csv(b"a,b,c\n1,2,3").write_csv(f.name)
    f.seek(0)

    lf = pl.scan_csv(f.name, include_file_paths="file_path")

    print(lf.drop("file_path").collect())
    print(lf.drop("file_path").collect(streaming=True))


    .collect()

    shape: (1, 4)
    ┌─────┬─────┬─────┬─────────────────────────────────┐
    │ a ┆ b ┆ c ┆ file_path │
    │ --- ┆ --- ┆ --- ┆ --- │
    │ i64 ┆ i64 ┆ i64 ┆ str │
    ╞═════╪═════╪═════╪═════════════════════════════════╡
    │ 1 ┆ 2 ┆ 3 ┆ /var/folders/fq/6gcccvqd08v2px… │
    └─────┴─────┴─────┴─────────────────────────────────┘


    .collect(streaming=True)

    shape: (1, 3)
    ┌─────┬─────┬─────┐
    │ a ┆ b ┆ c │
    │ --- ┆ --- ┆ --- │
    │ i64 ┆ i64 ┆ i64 │
    ╞═════╪═════╪═════╡
    │ 1 ┆ 2 ┆ 3 │
    └─────┴─────┴─────┘


    How can I exclude the column without streaming?

    Continue reading...

Compartilhe esta Página