pyspark.sql.functions.zeroifnull#
- pyspark.sql.functions.zeroifnull(col)[source]#
Returns zero if col is null, or col otherwise.
New in version 4.0.0.
- Parameters
- col
Column
or str
- col
Examples
>>> df = spark.createDataFrame([(None,), (1,)], ["a"]) >>> df.select(zeroifnull(df.a).alias("result")).show() +------+ |result| +------+ | 0| | 1| +------+