Spec-Zone.ru › Polars

polars.Expr.round_sig_figs

Expr.round_sig_figs(
    digits: int,
) → Expr

Round to a number of significant figures.

engine:In MemoryStreamingDistributed
Parameters:
digits

Number of significant figures to round to.

See also

ceil

Round up to the nearest integer.

floor

Round down to the nearest integer.

round

Round to a given number of decimals.

truncate

Truncate to a given number of decimals.

Examples

>>> df = pl.DataFrame({"a": [0.01234, 3.333, 1234.0]})
>>> df.with_columns(pl.col("a").round_sig_figs(2).alias("round_sig_figs"))
shape: (3, 2)
┌─────────┬────────────────┐
│ a       ┆ round_sig_figs │
│ ---     ┆ ---            │
│ f64     ┆ f64            │
╞═════════╪════════════════╡
│ 0.01234 ┆ 0.012          │
│ 3.333   ┆ 3.3            │
│ 1234.0  ┆ 1200.0         │
└─────────┴────────────────┘

© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/expressions/api/polars.Expr.round_sig_figs.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API