tabsdata.tableframe.expr.expr.Expr.shrink_dtype#

Expr.shrink_dtype() Expr[source]#

Cast down a column to the smallest type that can hold the element values.

Example:

>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("val"), td.col("val").shrink_dtype()
>>>   .alias("shrink_dtype"))
>>>
┌───────┬──────────────┐
│ val   ┆ shrink_dtype │
│ ---   ┆ ---          │
│ i64   ┆ i32          │
╞═══════╪══════════════╡
│ 0     ┆ 0            │
│ 256   ┆ 256          │
│ 65025 ┆ 65025        │
└───────┴──────────────┘