snowflake.snowpark.functions.zeroifnull

snowflake.snowpark.functions.zeroifnull(expr: Union[snowflake.snowpark.column.Column, str]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.43.0/src/snowflake/snowpark/_functions/scalar_functions.py#L4562-L4580)

Returns zero if the input expression is None; otherwise, returns the input expression.

Parameters:

expr (ColumnOrName) – The input expression to evaluate for None values.

Returns:

Zero if the input expression is None, otherwise the original value.

Return type:

Column

Examples::
>>> from snowflake.snowpark.functions import col
>>> df = session.create_dataframe([[1], [None], [5], [0]], schema=["a"])
>>> df.select(zeroifnull(col("a")).alias("result")).collect()
[Row(RESULT=1), Row(RESULT=0), Row(RESULT=5), Row(RESULT=0)]
Copy
语言: 中文