series_stats()series_stats()

series_stats() 使用多个列返回数字序列的统计信息。series_stats() returns statistics for a numerical series using multiple columns.

series_stats() 函数将一个返回动态数值数组的表达式作为输入,并计算以下统计信息:The series_stats() function takes an expression returning a dynamical numerical array as input, and calculates the following statistics:

统计信息Statistic 说明Description
min 输入数组中的最小值。Minimum value in the input array.
min_idx 输入数组中最小值的第一个位置。The first position of the minimum value in the input array.
max 输入数组中的最大值。Maximum value in the input array.
max_idx 输入数组中最大值的第一个位置。First position of the maximum value in the input array.
avg 输入数组的平均值。Average value of the input array.
variance 输入数组的样本方差。Sample variance of input array.
stdev 输入数组的样本标准偏差。Sample standard deviation of the input array.

备注

此函数返回多个值,因此不能将其用作其他函数的输入。This function returns multiple values, so it can't be used as the input for another function. 如果只需要单个值(如“average”),请考虑使用 series_stats_dynamicConsider using series_stats_dynamic if you only need a single value, such as "average".

语法Syntax

... | extend series_stats ( Expr [, IgnoreNonFinite] )... | extend series_stats ( Expr [, IgnoreNonFinite] )

... | extend ( Name1 [, Name2...] ) = series_stats ( Expr [, IgnoreNonFinite] )... | extend ( Name1 [, Name2...] ) = series_stats ( Expr [, IgnoreNonFinite] )

参数Arguments

  • Expr:一个返回 dynamic 类型值的表达式,该值包含一个数值数组。Expr: An expression that returns a value of type dynamic, holding an array of numeric values. 数值是为其定义了算术运算符的值。Numeric values are values for which arithmetic operators are defined.

  • IgnoreNonFinite:一个布尔表达式,指定是否在计算统计信息时忽略 Expr 的非有限值(nullNaNinf 等)。IgnoreNonFinite: A Boolean expression that specifies whether to calculate the statistics while ignoring non-finite values of Expr (null, NaN, inf, and so on). 如果为 false,则 Expr 中具有此值的单个项会为所有统计值生成一个值,即 nullIf false, a single item in Expr with this value will result in a value of null generated for all statistics values. 默认值为 falseThe default value is false.

返回Returns

语法 1Syntax 1

下面的语法导致添加以下新列(其中 Expr 是列引用 x):series_stats_x_minseries_stats_x_idx,依此类推。The following syntax results in the following new columns being added where Expr is the column reference x: series_stats_x_min, series_stats_x_idx, and so on.

... | extend series_stats ( Expr [, IgnoreNonFinite] )... | extend series_stats ( Expr [, IgnoreNonFinite] )

语法 2Syntax 2

下面的语法生成名为 Name1Name2 之类的列,并按顺序包含这些值。The following syntax results in columns named Name1, Name2, and so on, containing these values in order.

... | extend ( Name1 [, Name2...] ) = series_stats ( Expr [, IgnoreNonFinite] )... | extend ( Name1 [, Name2...] ) = series_stats ( Expr [, IgnoreNonFinite] )

示例Example

print x=dynamic([23,46,23,87,4,8,3,75,2,56,13,75,32,16,29]) 
| project series_stats(x)

series_stats_x_minseries_stats_x_min series_stats_x_min_idxseries_stats_x_min_idx series_stats_x_maxseries_stats_x_max series_stats_x_max_idxseries_stats_x_max_idx series_stats_x_avgseries_stats_x_avg series_stats_x_stdevseries_stats_x_stdev series_stats_x_varianceseries_stats_x_variance
22 88 8787 33 32.832.8 28.503633853548328.5036338535483 812.457142857143812.457142857143