cbrt
Computes the cube-root of the given value. Supports Spark Connect.
For the corresponding Databricks SQL function, see cbrt function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.cbrt(col=<col>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| target column to compute on. |
Returns
pyspark.sql.Column: the column for computed results.
Examples
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(-8,), (0,), (8,)], ["value"])
df.select("*", dbf.cbrt(df.value)).show()
Output
+-----+-----------+
|value|CBRT(value)|
+-----+-----------+
| -8| -2.0|
| 0| 0.0|
| 8| 2.0|
+-----+-----------+
Python
from pyspark.databricks.sql import functions as dbf
spark.sql("SELECT * FROM VALUES (FLOAT('NAN')), (NULL) AS TAB(value)").select("*", dbf.cbrt("value")).show()
Output
+-----+-----------+
|value|CBRT(value)|
+-----+-----------+
| NaN| NaN|
| NULL| NULL|
+-----+-----------+