tabsdata.tableframe.expr.expr.Expr.clip#
- Expr.clip(lower_bound: NumericLiteral | TemporalLiteral | IntoExprColumn | None = None, upper_bound: NumericLiteral | TemporalLiteral | IntoExprColumn | None = None) Expr [source]#
For element values outside the lower and upper bounds, lower values are replaced with the lower bound and upper values with the upper bound. Values within the lower and upper bounds are unaffected.
- Parameters:
lower_bound – The lower bound value. If None, the lower bound is not set.
upper_bound – The upper bound value. If None, the upper bound is
Example:
>>> import tabsdata as td >>> >>> tf: td.TableFrame ... >>> >>> tf = tf.select(td.col("age"), td.col("age").clip(18,65).alias("clip")) >>> ┌──────┬─────────┐ │ age ┆ clip │ │ --- ┆ ------- │ │ i64 ┆ i64 │ ╞══════╪═══+++═══╡ │ 1 ┆ 18 │ │ 18 ┆ 18 │ │ 50 ┆ 50 │ │ 65 ┆ 65 │ │ 70 ┆ 65 │ └──────┴─────────┘