Skip to main content
Version: 0.9.5

Expr.round_sig_figs

def round_sig_figs(digits: int) -> Expr

Categories: numeric

Round floating point element values to the specified significant figures.

Parameters

parameter
digits

number 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.01230.012
2.02442.0
0.00.0
│ inf ┆ NaN │
50.050.0
1.01.0
│ NaN ┆ NaN │
│ null ┆ null │
112.0110.0
2142.02100.0
└────────┴────────────────┘