Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
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|
+-----+------------+