convert_units
laktory.polars.expressions.convert_units
ยค
convert_units(x, input_unit, output_unit)
Units conversion
PARAMETER | DESCRIPTION |
---|---|
x
|
Input column
TYPE:
|
input_unit
|
Input units
TYPE:
|
output_unit
|
Output units
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Expr
|
Output column |
Examples:
import laktory # noqa: F401
import polars as pl
df = pl.DataFrame({"x": [1.0]})
df = df.with_columns(
y=pl.Expr.laktory.convert_units(pl.col("x"), input_unit="m", output_unit="ft")
)
print(df.glimpse(return_as_string=True))
'''
Rows: 1
Columns: 2
$ x <f64> 1.0
$ y <f64> 3.280839895013124
'''
References
The units conversion function use planck convert as a backend.
Source code in laktory/polars/expressions/units.py
14 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 |
|