Piezīmes
Lai piekļūtu šai lapai, ir nepieciešama autorizācija. Varat mēģināt pierakstīties vai mainīt direktorijus.
Lai piekļūtu šai lapai, ir nepieciešama autorizācija. Varat mēģināt mainīt direktorijus.
Returns col2 if col1 is not null, or col3 otherwise.
For the corresponding Databricks SQL function, see nvl2 function.
Syntax
from pyspark.sql import functions as dbf
dbf.nvl2(col1=<col1>, col2=<col2>, col3=<col3>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col1 |
pyspark.sql.Column or str |
The column to check. |
col2 |
pyspark.sql.Column or str |
The value to return if col1 is not null. |
col3 |
pyspark.sql.Column or str |
The value to return if col1 is null. |
Examples
from pyspark.sql import functions as dbf
df = spark.createDataFrame([(None, 8, 6,), (1, 9, 9,)], ["a", "b", "c"])
df.select('*', dbf.nvl2(df.a, df.b, df.c)).show()
+----+---+---+-------------+
| a| b| c|nvl2(a, b, c)|
+----+---+---+-------------+
|NULL| 8| 6| 6|
| 1| 9| 9| 9|
+----+---+---+-------------+