withNullFill
Syntax
withNullFill(func, x, y, fillValue)
Arguments
func is a DolphinDB built-in function with two inputs, such as
+
, -
, *
, /
,
\
, %
, pow
,
and
, or
, etc.
x and y are vectors or matrices.
fillValue is a scalar.
Details
If only 1 of the elements at the same location of x and y is NULL, replace the NULL value with fillValue in the calculation. If both elements at the same location of x and y are NULL, return NULL.
Examples
x = 0 1 NULL NULL 2
y = 1 NULL 2 NULL 3;
add(x,y);
// output
[1,,,,5]
withNullFill(add, x, y, 0);
// output
[1,1,2,,5]
m=matrix(1..5, y);
m;
col1 | col2 |
---|---|
1 | 1 |
2 | |
3 | 2 |
4 | |
5 | 3 |
add(x, m);
col1 | col2 |
---|---|
1 | 1 |
3 | |
7 | 5 |
withNullFill(add, x, m, 0);
col1 | col2 |
---|---|
1 | 1 |
3 | 1 |
3 | 2 |
4 | |
7 | 5 |