roundp
laktory.spark.functions.roundp
ยค
roundp(x, p=1.0)
Evenly round to the given precision
PARAMETER | DESCRIPTION |
---|---|
x
|
Input column
TYPE:
|
p
|
Precision
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Column
|
Output column |
Examples:
import laktory # noqa: F401
import pyspark.sql.functions as F
df = spark.createDataFrame([[0.781], [13.0]], ["x"])
df = df.withColumn("y", F.laktory.roundp("x", p=5))
print(df.laktory.show_string())
'''
+-----+----+
| x| y|
+-----+----+
|0.781| 0.0|
| 13.0|15.0|
+-----+----+
'''
df = df.withColumn("y", F.laktory.roundp("x", p=0.25))
print(df.laktory.show_string())
'''
+-----+----+
| x| y|
+-----+----+
|0.781|0.75|
| 13.0|13.0|
+-----+----+
'''
Source code in laktory/spark/functions/math.py
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 61 62 63 64 65 66 67 68 69 70 71 72 |
|