Share via


log1p

Computes the natural logarithm of the given value plus one. Supports Spark Connect.

For the corresponding Databricks SQL function, see log1p function.

Syntax

from pyspark.databricks.sql import functions as dbf

dbf.log1p(col=<col>)

Parameters

Parameter Type Description
col pyspark.sql.Column or column name column to calculate natural logarithm for.

Returns

pyspark.sql.Column: natural logarithm of the "given value plus one".

Examples

from pyspark.databricks.sql import functions as dbf
spark.range(1).select(dbf.log1p(dbf.e())).show()
+------------------+
|        LOG1P(E())|
+------------------+
|1.3132616875182...|
+------------------+

from pyspark.databricks.sql import functions as dbf
spark.range(1).select(dbf.log(dbf.e() + 1)).show()
+------------------+
|     ln((E() + 1))|
+------------------+
|1.3132616875182...|
+------------------+