pyspark.sql.functions.power#
- pyspark.sql.functions.power(col1, col2)#
Returns the value of the first argument raised to the power of the second argument.
New in version 1.4.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- Returns
Column
the base rased to the power the argument.
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| +---+------------+