roundp
laktory.polars.expressions.roundp
ยค
roundp(x, p=1.0)
Evenly round to the given precision
PARAMETER | DESCRIPTION |
---|---|
x
|
Input column
TYPE:
|
p
|
Precision |
RETURNS | DESCRIPTION |
---|---|
Expr
|
Output column |
Examples:
import laktory # noqa: F401
import polars as pl
df = pl.DataFrame([[0.781], [13.0]], ["x"])
df = df.with_columns(y=pl.Expr.laktory.roundp(pl.col("x"), p=5))
print(df.glimpse(return_as_string=True))
'''
Rows: 2
Columns: 2
$ x <f64> 0.781, 13.0
$ y <f64> 0.0, 15.0
'''
df = df.with_columns(y=pl.Expr.laktory.roundp(pl.col("x"), p=0.25))
print(df.glimpse(return_as_string=True))
'''
Rows: 2
Columns: 2
$ x <f64> 0.781, 13.0
$ y <f64> 0.75, 13.0
'''
Source code in laktory/polars/expressions/math.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|