pyspark.sql.functions.log1p#
- pyspark.sql.functions.log1p(col)[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 column name column to calculate natural logarithm for.
- col
- Returns
Column
natural logarithm of the “given value plus one”.
Examples
>>> from pyspark.sql import functions as sf >>> spark.range(1).select(sf.log1p(sf.e())).show() +------------------+ | LOG1P(E())| +------------------+ |1.3132616875182...| +------------------+
Same as:
>>> spark.range(1).select(sf.log(sf.e() + 1)).show() +------------------+ | ln((E() + 1))| +------------------+ |1.3132616875182...| +------------------+