Expr.round_sig_figs
methodView source ↗
def round_sig_figs(digits: int) -> Expr
Categories: numeric
Round floating point element values to the specified significant figures.
Parameters
parameter
digitsnumber of digits to round up.
Examples
>>> import tabsdata as td
>>>
>>> tf: td.TableFrame ...
>>>
>>> tf.select(td.col("val"), td.col("val").round_sig_figs(2)
>>> .alias("round_sig_figs"))
>>>
┌────────┬────────────────┐
│ val ┆ round_sig_figs │
│ --- ┆ --- │
│ f64 ┆ f64 │
╞════════╪════════════════╡
│ 0.0123 ┆ 0.012 │
│ 2.0244 ┆ 2.0 │
│ 0.0 ┆ 0.0 │
│ inf ┆ NaN │
│ 50.0 ┆ 50.0 │
│ 1.0 ┆ 1.0 │
│ NaN ┆ NaN │
│ null ┆ null │
│ 112.0 ┆ 110.0 │
│ 2142.0 ┆ 2100.0 │
└────────┴────────────────┘