foundryts.functions.mean¶
foundryts.functions.mean()¶
Returns a function that computes the mean of all points sharing a timestamp for multiple input time series.
The resulting time series is a union of all timestamps for all the input time series, where each timestamp contains the means of values that exist across the input set for that timestamp.
- Returns: A function that accepts multiple time series as inputs and generates a single time series contains a union of all timestamps with the values as the mean of all points in the input time series that share a timestamp.
- Return type: (NodeCollection) -> FunctionNode
Dataframe schema¶
| Column name | Type | Description |
|---|---|---|
| timestamp | pandas.Timestamp | Timestamp of the point |
| value | float | Value of the point |
:::callout{theme="success" title="See Also"}
sum()
:::
:::callout{theme="warning" title="Note"} This function is only applicable to numeric series. :::
Examples¶
>>> series_1 = F.points(
... (0, 0.0),
... (100, 100.0),
... (140, 140.0),
... (200, 200.0),
... name="series-1"
... )
>>> series_2 = F.points(
... (100, 200.0),
... (120, 220.0),
... (130, 330.0),
... (150, 350.0),
... (160, 460.0),
... name="series-2"
... )
>>> series_1.to_pandas()
timestamp value
0 1970-01-01 00:00:00.000000000 0.0
1 1970-01-01 00:00:00.000000100 100.0
2 1970-01-01 00:00:00.000000140 140.0
3 1970-01-01 00:00:00.000000200 200.0
>>> series_2.to_pandas()
timestamp value
0 1970-01-01 00:00:00.000000100 200.0
1 1970-01-01 00:00:00.000000120 220.0
2 1970-01-01 00:00:00.000000130 330.0
3 1970-01-01 00:00:00.000000150 350.0
4 1970-01-01 00:00:00.000000160 460.0
>>> mean_series = F.mean()([series_1, series_2, series_2])
>>> mean_series.to_pandas()
timestamp value
0 1970-01-01 00:00:00.000000000 0.000000
1 1970-01-01 00:00:00.000000100 166.666667
2 1970-01-01 00:00:00.000000120 220.000000
3 1970-01-01 00:00:00.000000130 330.000000
4 1970-01-01 00:00:00.000000140 140.000000
5 1970-01-01 00:00:00.000000150 350.000000
6 1970-01-01 00:00:00.000000160 460.000000
7 1970-01-01 00:00:00.000000200 200.000000
中文翻译¶
foundryts.functions.mean¶
foundryts.functions.mean()¶
返回一个函数,用于计算多个输入时间序列中共享同一时间戳的所有数据点的平均值(mean)。
生成的时间序列是所有输入时间序列时间戳的并集,其中每个时间戳包含该时间戳下输入集合中存在的值的平均值。
- 返回值: 一个函数,接受多个时间序列作为输入,并生成一个单一的时间序列,该序列包含所有时间戳的并集,其值为输入时间序列中共享同一时间戳的所有数据点的平均值。
- 返回类型: (NodeCollection) -> FunctionNode
数据框模式(Dataframe schema)¶
| 列名 | 类型 | 描述 |
|---|---|---|
| timestamp | pandas.Timestamp | 数据点的时间戳 |
| value | float | 数据点的值 |
:::callout{theme="success" title="另请参阅"}
sum()
:::
:::callout{theme="warning" title="注意"} 此函数仅适用于数值型序列。 :::
示例¶
>>> series_1 = F.points(
... (0, 0.0),
... (100, 100.0),
... (140, 140.0),
... (200, 200.0),
... name="series-1"
... )
>>> series_2 = F.points(
... (100, 200.0),
... (120, 220.0),
... (130, 330.0),
... (150, 350.0),
... (160, 460.0),
... name="series-2"
... )
>>> series_1.to_pandas()
timestamp value
0 1970-01-01 00:00:00.000000000 0.0
1 1970-01-01 00:00:00.000000100 100.0
2 1970-01-01 00:00:00.000000140 140.0
3 1970-01-01 00:00:00.000000200 200.0
>>> series_2.to_pandas()
timestamp value
0 1970-01-01 00:00:00.000000100 200.0
1 1970-01-01 00:00:00.000000120 220.0
2 1970-01-01 00:00:00.000000130 330.0
3 1970-01-01 00:00:00.000000150 350.0
4 1970-01-01 00:00:00.000000160 460.0
>>> mean_series = F.mean()([series_1, series_2, series_2])
>>> mean_series.to_pandas()
timestamp value
0 1970-01-01 00:00:00.000000000 0.000000
1 1970-01-01 00:00:00.000000100 166.666667
2 1970-01-01 00:00:00.000000120 220.000000
3 1970-01-01 00:00:00.000000130 330.000000
4 1970-01-01 00:00:00.000000140 140.000000
5 1970-01-01 00:00:00.000000150 350.000000
6 1970-01-01 00:00:00.000000160 460.000000
7 1970-01-01 00:00:00.000000200 200.000000