pyspark.sql.functions.sqrt#
- pyspark.sql.functions.sqrt(col)[source]#
Computes the square root of the specified float value.
New in version 1.3.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- col
Column
or column name target column to compute on.
- col
- Returns
Column
column for computed results.
Examples
>>> from pyspark.sql import functions as sf >>> spark.sql( ... "SELECT * FROM VALUES (-1), (0), (1), (4), (NULL) AS TAB(value)" ... ).select("*", sf.sqrt("value")).show() +-----+-----------+ |value|SQRT(value)| +-----+-----------+ | -1| NaN| | 0| 0.0| | 1| 1.0| | 4| 2.0| | NULL| NULL| +-----+-----------+