Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Round the given value to scale decimal places using HALF_EVEN rounding mode if scale >= 0 or at integral part when scale < 0. Supports Spark Connect.
For the corresponding Databricks SQL function, see bround function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.bround(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.bround(dbf.lit(2.5))).show()
+--------------+
|bround(2.5, 0)|
+--------------+
| 2.0|
+--------------+
from pyspark.databricks.sql import functions as dbf
spark.range(1).select(dbf.bround(dbf.lit(2.1267), dbf.lit(2))).show()
+-----------------+
|bround(2.1267, 2)|
+-----------------+
| 2.13|
+-----------------+