pyspark.sql.functions.log2#
- pyspark.sql.functions.log2(col)[source]#
Returns the base-2 logarithm of the argument.
New in version 1.5.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- col
Column
or str a column to calculate logariphm for.
- col
- Returns
Column
logariphm of given value.
Examples
>>> df = spark.createDataFrame([(4,)], ['a']) >>> df.select(log2('a').alias('log2')).show() +----+ |log2| +----+ | 2.0| +----+