polars.select
-
Run polars expressions without a context.
This is syntactic sugar for running
df.selecton an empty DataFrame (or LazyFrame if eager=False).- Parameters:
-
- *exprs
-
Column(s) to select, specified as positional arguments. Accepts expression input. Strings are parsed as column names, other non-expression inputs are parsed as literals.
- eager
-
Evaluate immediately and return a
DataFrame(default); if set toFalse, return aLazyFrameinstead. - **named_exprs
-
Additional columns to select, specified as keyword arguments. The columns will be renamed to the keyword used.
- Returns:
-
- DataFrame or LazyFrame
Examples
>>> foo = pl.Series("foo", [1, 2, 3]) >>> bar = pl.Series("bar", [3, 2, 1]) >>> pl.select(min=pl.min_horizontal(foo, bar)) shape: (3, 1) ┌─────┐ │ min │ │ --- │ │ i64 │ ╞═════╡ │ 1 │ │ 2 │ │ 1 │ └─────┘>>> pl.select(pl.int_range(0, 100_000, 2).alias("n"), eager=False).filter( ... pl.col("n") % 22_500 == 0 ... ).collect() shape: (5, 1) ┌───────┐ │ n │ │ --- │ │ i64 │ ╞═══════╡ │ 0 │ │ 22500 │ │ 45000 │ │ 67500 │ │ 90000 │ └───────┘
polars.select(
*exprs: IntoExpr | Iterable[IntoExpr],
eager: bool = True,
**named_exprs: IntoExpr,
) → DataFrame | LazyFrame
© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/expressions/api/polars.select.html