series_fill_const()
Learn how to use the series_fill_const() function to replace missing values in a series with a specified constant value.
Replaces missing values in a series with a specified constant value.
Takes an expression containing dynamic numerical array as input, replaces all instances of missing_value_placeholder with the specified constant_value and returns the resulting array.
Syntax
series_fill_const(series, constant_value, [ missing_value_placeholder ])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| series | dynamic | ✔️ | An array of numeric values. |
| constant_value | scalar | ✔️ | The value used to replace the missing values. |
| missing_value_placeholder | scalar | Specifies a placeholder for missing values. The default value is double(null). The value can be of any type that will be converted to actual element types. double(null), long(null) and int(null) have the same meaning. |
Returns
series with all instances of missing_value_placeholder replaced with constant_value.
Example
let data = datatable(arr: dynamic)
[
dynamic([111, null, 36, 41, 23, null, 16, 61, 33, null, null])
];
data
| project
arr,
fill_const1 = series_fill_const(arr, 0.0),
fill_const2 = series_fill_const(arr, -1)
Output
arr | fill_const1 | fill_const2 |
|---|---|---|
| [111,null,36,41,23,null,16,61,33,null,null] | [111,0.0,36,41,23,0.0,16,61,33,0.0,0.0] | [111,-1,36,41,23,-1,16,61,33,-1,-1] |
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.