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