Expr.clip
methodView source ↗
def clip(
lower_bound: NumericLiteral | TemporalLiteral | IntoExprColumn | None = None,
upper_bound: NumericLiteral | TemporalLiteral | IntoExprColumn | None = None,
) -> Expr
Categories: numeric
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
parameter
lower_boundThe lower bound value. If None, the lower bound is not set.
parameter
upper_boundThe upper bound value. If None, the upper bound is
Examples
>>> 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 │
└──────┴─────────┘