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.
Computes the square root of the specified float value. Supports Spark Connect.
For the corresponding Databricks SQL function, see sqrt function.
Syntax
from pyspark.sql import functions as dbf
dbf.sqrt(col=<col>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or column name |
target column to compute on. |
Returns
pyspark.sql.Column: column for computed results.
Examples
from pyspark.sql import functions as dbf
spark.sql(
"SELECT * FROM VALUES (-1), (0), (1), (4), (NULL) AS TAB(value)"
).select("*", dbf.sqrt("value")).show()
+-----+-----------+
|value|SQRT(value)|
+-----+-----------+
| -1| NaN|
| 0| 0.0|
| 1| 1.0|
| 4| 2.0|
| NULL| NULL|
+-----+-----------+