Skip to main content
Version: 1.8.0

Expr.clip

def clip(
lower_bound: td_NumericLiteral | td_TemporalLiteral | td_IntoExprColumn | None = None,
upper_bound: td_NumericLiteral | td_TemporalLiteral | td_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_bound

The lower bound value. If None, the lower bound is not set.

parameter
upper_bound

The 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 │
╞══════╪═══+++═══╡
118
1818
5050
6565
7065
└──────┴─────────┘