Method: Polars::Functions#select

Defined in:
lib/polars/functions/lazy.rb

#select(*exprs, eager: true, **named_exprs) ⇒ DataFrame

Run polars expressions without a context.

This is syntactic sugar for running df.select on an empty DataFrame.

Examples:

foo = Polars::Series.new("foo", [1, 2, 3])
bar = Polars::Series.new("bar", [3, 2, 1])
Polars.select(min: Polars.min_horizontal(foo, bar))
# =>
# shape: (3, 1)
# ┌─────┐
# │ min │
# │ --- │
# │ i64 │
# ╞═════╡
# │ 1   │
# │ 2   │
# │ 1   │
# └─────┘

Parameters:

  • exprs (Array)

    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 (Boolean) (defaults to: true)

    Evaluate immediately and return a DataFrame (default); if set to false, return a LazyFrame instead.

  • named_exprs (Hash)

    Additional columns to select, specified as keyword arguments. The columns will be renamed to the keyword used.

Returns:



1603
1604
1605
1606
# File 'lib/polars/functions/lazy.rb', line 1603

def select(*exprs, eager: true, **named_exprs)
  empty_frame = eager ? Polars::DataFrame.new : Polars::LazyFrame.new
  empty_frame.select(*exprs, **named_exprs)
end