Note
Kailangan ng pahintulot para ma-access ang page na ito. Maaari mong subukang mag-sign in o magpalit ng mga direktoryo.
Ang pag-access sa pahinang ito ay nangangailangan ng pahintulot. Maaari mong subukang baguhin ang mga direktoryo.
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.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.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.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|
+-----+------------+