snowflake.snowpark.functions.div0¶
- snowflake.snowpark.functions.div0(dividend: ColumnOrName | int | float, divisor: ColumnOrName | int | float) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/release-v1.3.0/src/snowflake/snowpark/functions.py#L1127-L1150)¶
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'))]