polars.Expr.clip_min#
- Expr.clip_min(lower_bound: int | float) Self [source]#
Clip (limit) the values in an array to a min boundary.
Only works for numerical types.
If you want to clip other dtypes, consider writing a “when, then, otherwise” expression. See
when()
for more information.- Parameters:
- lower_bound
Lower bound.
Examples
>>> df = pl.DataFrame({"foo": [-50, 5, None, 50]}) >>> df.with_columns(pl.col("foo").clip_min(0).alias("foo_clipped")) shape: (4, 2) ┌──────┬─────────────┐ │ foo ┆ foo_clipped │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞══════╪═════════════╡ │ -50 ┆ 0 │ │ 5 ┆ 5 │ │ null ┆ null │ │ 50 ┆ 50 │ └──────┴─────────────┘