PySpark SQL Functions | round method
Start your free 7-days trial now!
PySpark SQL Functions'
round(~) method rounds the values of the specified column.
The column to perform rounding on.
If scale is positive, such as
scale=2, then values are rounded to the nearest 2nd decimal. If scale is negative, such as
scale=-1, then values are rounded to the nearest tenth. By default,
scale=0, that is, values are rounded to the nearest integer.
A PySpark Column (
Consider the following PySpark DataFrame:
Rounding column values to the nearest integer
To round to the nearest integer:
100.5 got rounded up to
Rounding column values to the nearest first decimal
To round to the nearest 1st decimal:
Rounding column values to the nearest tenth
To round to the nearest tenth: