pyspark.sql.functions.
round
Round the given value to scale decimal places using HALF_UP rounding mode if scale >= 0 or at integral part when scale < 0.
New in version 1.5.0.
Changed in version 3.4.0: Supports Spark Connect.
Column
input column to round.
scale value.
rounded values.
Examples
>>> spark.createDataFrame([(2.5,)], ['a']).select(round('a', 0).alias('r')).collect() [Row(r=3.0)]