Partager via


log

S’il n’y a qu’un seul argument, cela prend le logarithme naturel de l’argument. Prend en charge Spark Connect.

Pour obtenir plus de détails sur la fonction SQL de Databricks correspondante, consultez log.

Syntaxe

from pyspark.databricks.sql import functions as dbf

dbf.log(arg1=<arg1>, arg2=<arg2>)

Paramètres

Paramètre Type Descriptif
arg1 pyspark.sql.Column, str or float nombre de base ou nombre réel (dans ce cas, base est e)
arg2 pyspark.sql.Column, str or float, optional nombre pour lequel calculer logariphm.

Retours

pyspark.sql.Column: logariphm de valeur donnée.

Examples

from pyspark.databricks.sql import functions as dbf
df = spark.sql("SELECT * FROM VALUES (1), (2), (4) AS t(value)")
df.select("*", dbf.log(2.0, df.value)).show()
+-----+---------------+
|value|LOG(2.0, value)|
+-----+---------------+
|    1|            0.0|
|    2|            1.0|
|    4|            2.0|
+-----+---------------+

from pyspark.databricks.sql import functions as dbf
df = spark.sql("SELECT * FROM VALUES (1), (2), (0), (-1), (NULL) AS t(value)")
df.select("*", dbf.log(3.0, df.value)).show()
+-----+------------------+
|value|   LOG(3.0, value)|
+-----+------------------+
|    1|               0.0|
|    2|0.6309297535714...|
|    0|              NULL|
|   -1|              NULL|
| NULL|              NULL|
+-----+------------------+