pola-rs / polars

Dataframes powered by a multithreaded, vectorized query engine, written in Rust
https://docs.pola.rs
Other
26.9k stars 1.65k forks source link

non strict columns selection when specifying column names #16219

Closed kbzsl closed 2 weeks ago

kbzsl commented 2 weeks ago

Description

The ColumnNotFoundError error is thrown when a column is missing from the provided column list.

There can be situations when having optional columns; in these cases having a non-strict column selection would simplify the code.
(as workaround I am using list comprehension to remove the non-existing columns from the column list before the .select())

Something like cs.any_of() (inspired by tidyselect).

alexander-beedie commented 2 weeks ago

Looks like https://github.com/pola-rs/polars/pull/15028 would handle this; currently pending merge 👌

stinodego commented 2 weeks ago

Duplicate of #15023