Bemærk
Adgang til denne side kræver godkendelse. Du kan prøve at logge på eller ændre mapper.
Adgang til denne side kræver godkendelse. Du kan prøve at ændre mapper.
Computes the logarithm of the given value in Base 10. Supports Spark Connect.
For the corresponding Databricks SQL function, see log10 function.
Syntax
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
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(1,), (10,), (100,)], ["value"])
df.select("*", dbf.log10(df.value)).show()
+-----+------------+
|value|LOG10(value)|
+-----+------------+
| 1| 0.0|
| 10| 1.0|
| 100| 2.0|
+-----+------------+
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()
+-----+------------+
|value|LOG10(value)|
+-----+------------+
| -1.0| NULL|
| 0.0| NULL|
| NaN| NaN|
| NULL| NULL|
+-----+------------+