pyspark.sql.functions.pow#

pyspark.sql.functions.pow(col1, col2)[source]#

Returns the value of the first argument raised to the power of the second argument.

Added in version 1.4.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters:
col1Column, column name or float

the base number. A column that evaluates to a double.

col2Column, column name or float

the exponent number. A column that evaluates to a double.

Returns:
Column

the base rased to the power the argument. Returns a column that evaluates to a double.

Examples

>>> from pyspark.sql import functions as sf
>>> spark.range(5).select("*", sf.pow("id", 2)).show()
+---+------------+
| id|POWER(id, 2)|
+---+------------+
|  0|         0.0|
|  1|         1.0|
|  2|         4.0|
|  3|         9.0|
|  4|        16.0|
+---+------------+