Filter a single column.
Alias for #filter.
df = Polars::DataFrame.new( { "group_col" => ["g1", "g1", "g2"], "b" => [1, 2, 3] } ) ( df.group_by("group_col").agg( [ Polars.col("b").where(Polars.col("b") < 2).sum.alias("lt"), Polars.col("b").where(Polars.col("b") >= 2).sum.alias("gte") ] ) ).sort("group_col") # => # shape: (2, 3) # ┌───────────┬─────┬─────┐ # │ group_col ┆ lt ┆ gte │ # │ --- ┆ --- ┆ --- │ # │ str ┆ i64 ┆ i64 │ # ╞═══════════╪═════╪═════╡ # │ g1 ┆ 1 ┆ 2 │ # │ g2 ┆ 0 ┆ 3 │ # └───────────┴─────┴─────┘
Parameters:
Boolean expression.
Returns:
2857 2858 2859
# File 'lib/polars/expr.rb', line 2857 def where(predicate) filter(predicate) end