series_fill_forward()series_fill_forward()

在序列中对缺失值执行前向填充内插。Performs a forward fill interpolation of missing values in a series.

包含动态数值数组的表达式为输入。An expression containing dynamic numerical array is the input. 该函数将 missing_value_placeholder 的所有实例替换为离其左侧最近的值(missing_value_placeholder 除外),并返回生成的数组。The function replaces all instances of missing_value_placeholder with the nearest value from its left side other than missing_value_placeholder, and returns the resulting array. 保留 missing_value_placeholder 的最左侧实例。The leftmost instances of missing_value_placeholder are preserved.

语法Syntax

series_fill_forward(x[, missing_value_placeholder])series_fill_forward(x[, missing_value_placeholder])

  • 将返回序列 x,其中前向填充了 missing_value_placeholder 的所有实例。Will return series x with all instances of missing_value_placeholder filled forwards.

参数Arguments

  • x:动态数组标量表达式(数值数组)。x: dynamic array scalar expression, which is an array of numeric values.
  • missing_value_placeholder:可选参数,用于指定要替换的缺失值的占位符。missing_value_placeholder: optional parameter, which specifies a placeholder for a missing value to be replaced. 默认值为“double(null)”。Default value is double(null).

备注Notes

  • 将“null”指定为默认值,以在 make-series 之后应用内插函数:Specify null as the default value to apply interpolation functions after make-series:
make-series num=count() default=long(null) on TimeStamp from ago(1d) to ago(1h) step 1h by Os, Browser
  • missing_value_placeholder 可以是将要转换为实际元素类型的任何类型。The missing_value_placeholder can be of any type that will be converted to actual element types. double(null)、long(null) 和 int(null) 具有相同的含义。Both double(null) long(null) and int(null) have the same meaning.
  • 如果 missing_value_placeholder 为 (null) 或被省略(二者含义相同),则结果可能包含 null 值。If missing_value_placeholder is (null) (or omitted - which have the same meaning), then a result may contain null values. 若要填充这些 null 值,请使用其他内插函数。To fill these null values, use other interpolation functions. 目前只有 series_outliers() 支持在输入数组中使用 null 值。Currently only series_outliers() support null values in input arrays.
  • 这些函数会保留数组元素的原始类型。The functions preserve the original type of array elements.

示例Example

let data = datatable(arr: dynamic)
[
    dynamic([null,null,36,41,null,null,16,61,33,null,null])   
];
data 
| project arr, 
          fill_forward = series_fill_forward(arr)  

arr fill_forward
[null,null,36,41,null,null,16,61,33,null,null][null,null,36,41,null,null,16,61,33,null,null] [null,null,36,41,41,41,16,61,33,33,33][null,null,36,41,41,41,16,61,33,33,33]

使用 series_fill_backwardseries-fill-const 完成以上数组的内插。Use series_fill_backward or series-fill-const to complete interpolation of the above array.