Σημείωση
Η πρόσβαση σε αυτή τη σελίδα απαιτεί εξουσιοδότηση. Μπορείτε να δοκιμάσετε να συνδεθείτε ή να αλλάξετε καταλόγους.
Η πρόσβαση σε αυτή τη σελίδα απαιτεί εξουσιοδότηση. Μπορείτε να δοκιμάσετε να αλλάξετε καταλόγους.
Round the given value to scale decimal places using HALF_UP rounding mode if scale >= 0 or at integral part when scale < 0. Supports Spark Connect.
For the corresponding Databricks SQL function, see round function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.round(col=<col>, scale=<scale>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or column name |
The target column or column name to compute the round on. |
scale |
pyspark.sql.Column or int, optional |
An optional parameter to control the rounding behavior. |
Returns
pyspark.sql.Column: A column for the rounded value.
Examples
from pyspark.databricks.sql import functions as dbf
spark.range(1).select(dbf.round(dbf.lit(2.5))).show()
+-------------+
|round(2.5, 0)|
+-------------+
| 3.0|
+-------------+
from pyspark.databricks.sql import functions as dbf
spark.range(1).select(dbf.round(dbf.lit(2.1267), dbf.lit(2))).show()
+----------------+
|round(2.1267, 2)|
+----------------+
| 2.13|
+----------------+