snowflake.snowpark.functions.div0¶
- snowflake.snowpark.functions.div0(dividend: Union[Column, str, int, float], divisor: Union[Column, str, int, float]) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/functions.py#L1988-L2014)¶
Performs division like the division operator (/), but returns 0 when the divisor is 0 (rather than reporting an error).
Example:
>>> df = session.create_dataframe([1], schema=["a"]) >>> df.select(div0(df["a"], 1).alias("divided_by_one"), div0(df["a"], 0).alias("divided_by_zero")).collect() [Row(DIVIDED_BY_ONE=Decimal('1.000000'), DIVIDED_BY_ZERO=Decimal('0.000000'))]