floor
Computes the floor of the given value. Supports Spark Connect.
For the corresponding Databricks SQL function, see floor function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.floor(col=<col>, scale=<scale>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| The target column or column name to compute the floor on. |
|
| An optional parameter to control the rounding behavior. |
Returns
pyspark.sql.Column: nearest integer that is less than or equal to given value.
Examples
Python
from pyspark.databricks.sql import functions as dbf
spark.range(1).select(dbf.floor(dbf.lit(2.5))).show()
Output
+----------+
|FLOOR(2.5)|
+----------+
| 2|
+----------+
Python
from pyspark.databricks.sql import functions as dbf
spark.range(1).select(dbf.floor(dbf.lit(2.1267), dbf.lit(2))).show()
Output
+----------------+
|floor(2.1267, 2)|
+----------------+
| 2.12|
+----------------+