pyspark.sql.functions.isnull#

pyspark.sql.functions.isnull(col)[source]#

An expression that returns true if the column is null.

New in version 1.6.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
colColumn or column name

target column to compute on.

Returns
Column

True if value is null and False otherwise.

Examples

>>> from pyspark.sql import functions as sf
>>> df = spark.createDataFrame([(1, None), (None, 2)], ("a", "b"))
>>> df.select("*", sf.isnull("a"), isnull(df.b)).show()
+----+----+-----------+-----------+
|   a|   b|(a IS NULL)|(b IS NULL)|
+----+----+-----------+-----------+
|   1|NULL|      false|       true|
|NULL|   2|       true|      false|
+----+----+-----------+-----------+