Skip to main content

log10

Computes the logarithm of the given value in Base 10. Supports Spark Connect.

For the corresponding Databricks SQL function, see log10 function.

Syntax

Python
from pyspark.databricks.sql import functions as dbf

dbf.log10(col=<col>)

Parameters

Parameter

Type

Description

col

pyspark.sql.Column or column name

column to calculate logarithm for.

Returns

pyspark.sql.Column: logarithm of the given value in Base 10.

Examples

Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(1,), (10,), (100,)], ["value"])
df.select("*", dbf.log10(df.value)).show()
Output
+-----+------------+
|value|LOG10(value)|
+-----+------------+
| 1| 0.0|
| 10| 1.0|
| 100| 2.0|
+-----+------------+

Python
from pyspark.databricks.sql import functions as dbf
spark.sql("SELECT * FROM VALUES (-1), (0), (FLOAT('NAN')), (NULL) AS TAB(value)").select("*", dbf.log10("value")).show()
Output
+-----+------------+
|value|LOG10(value)|
+-----+------------+
| -1.0| NULL|
| 0.0| NULL|
| NaN| NaN|
| NULL| NULL|
+-----+------------+