pyspark.sql.functions.log1p¶
-
pyspark.sql.functions.
log1p
(col: ColumnOrName) → pyspark.sql.column.Column[source]¶ Computes the natural logarithm of the “given value plus one”.
New in version 1.4.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- col
Column
or str column to calculate natural logarithm for.
- col
- Returns
Column
natural logarithm of the “given value plus one”.
Examples
>>> import math >>> df = spark.range(1) >>> df.select(log1p(lit(math.e))).first() Row(LOG1P(2.71828...)=1.31326...)
Same as:
>>> df.select(log(lit(math.e+1))).first() Row(ln(3.71828...)=1.31326...)