replaceIfNull
replaceIfNull
takes an array of values and a default value, and returns a new array where all of the null values in the original array are replaced with the default value.
Syntax
replaceIfNull(values, defaultValue)
Parameters
Parameter | Type | Description |
---|---|---|
values | byte[], char[], bool[], DateTime[], double[], float[], int[], long[], short[], String[] | The array of values to replace nulls in. |
defaultValue | byte, char, bool, DateTime, double, float, int, long, short, String | The value that replaces nulls in the array. |
replaceIfNull
can take almost any generic object array and default value as its arguments.
Returns
Returns a new array with null values replaced by the defaultValue
parameter.
Examples
from deephaven import new_table
from deephaven.column import string_col, int_col
from deephaven.constants import NULL_INT
source = new_table(
[
string_col("Strings", ["abc", "def", None]),
int_col("Integers", [100, 200, NULL_INT]),
]
)
default_string = "ghi"
default_int = 300
result = source.update(
formulas=[
"Strings = replaceIfNull(Strings, default_string)",
"Integers = replaceIfNull(Integers, default_int)",
]
)
- source
- result