zeroifnull

In [ ]:
zeroifnull(expr)

Evaluates to 0 if the expression is NULL.

Parameters

Name Type Optional Description
expr
object
❌
Expression.

Returns

str_sql : SQL expression.

Example

In [28]:
from verticapy import *
df = tablesample({"x": [0, None, 0.7, None]}).to_vdf()
display(df)
123
x
Numeric(19,1)
10.0
2[null]
30.7
4[null]
Rows: 1-4 | Column: x | Type: numeric(19,1)
In [29]:
# Importing the stats module
import verticapy.stats as st

# Applying the zeroifnull function
df["zeroifnull_x"] = st.zeroifnull(df["x"])
display(df)
123
x
Numeric(19,1)
123
zeroifnull_x
Numeric(19,1)
10.00.0
2[null]0.0
30.70.7
4[null]0.0
Rows: 1-4 | Columns: 2