pyspark.sql.functions.equal_null#

pyspark.sql.functions.equal_null(col1, col2)[source]#

Returns same result as the EQUAL(=) operator for non-null operands, but returns true if both are null, false if one of the them is null.

New in version 3.5.0.

Parameters
col1Column or str
col2Column or str

Examples

>>> df = spark.createDataFrame([(None, None,), (1, 9,)], ["a", "b"])
>>> df.select(equal_null(df.a, df.b).alias('r')).collect()
[Row(r=True), Row(r=False)]