跳转至

foundryts.functions.scale

foundryts.functions.scale(factor)

Returns a function that multiplies each value in a single time series by the specified factor.

For a source time series with points (timestamp, value), upon scaling by factor, the resulting scaled time series will have points (timestamp, value * factor).

  • Parameters: factor (float) – The scaling factor that is multiplied with the value of each point.
  • Returns: A function that accepts a single time series as input and returns the scaled time series.
  • Return type: (FunctionNode) -> FunctionNode

Dataframe schema

Column name Type Description
timestamp pandas.Timestamp Timestamp of the point
value float Scaled value of the point

:::callout{theme="success" title="See Also"} timestamp_scale(), value_shift() :::

:::callout{theme="warning" title="Note"} This function is only applicable to numeric series. :::

Examples

>>> series = F.points(
...     (100, 0.0),
...     (200, float("inf")),
...     (300, 3.14159),
...     (2147483647, 1.0),
...     name="series"
... )
>>> series.to_pandas()
                      timestamp    value
0 1970-01-01 00:00:00.000000100  0.00000
1 1970-01-01 00:00:00.000000200      inf
2 1970-01-01 00:00:00.000000300  3.14159
3 1970-01-01 00:00:02.147483647  1.00000
>>> scaled = F.scale(1.5)(series)
>>> scaled.to_pandas()
                      timestamp     value
0 1970-01-01 00:00:00.000000100  0.000000
1 1970-01-01 00:00:00.000000200       inf
2 1970-01-01 00:00:00.000000300  4.712385
3 1970-01-01 00:00:02.147483647  1.500000

中文翻译


foundryts.functions.scale

foundryts.functions.scale(factor)

返回一个函数,该函数将单个时间序列中的每个值乘以指定的因子(factor)。

对于包含数据点 (timestamp, value) 的源时间序列,按 factor 缩放后,生成的缩放时间序列将包含数据点 (timestamp, value * factor)

  • 参数: factorfloat)– 与每个数据点的值相乘的缩放因子。
  • 返回: 一个接受单个时间序列作为输入并返回缩放后时间序列的函数。
  • 返回类型: (FunctionNode) -> FunctionNode

数据框模式(Dataframe schema)

列名 类型 描述
timestamp pandas.Timestamp 数据点的时间戳
value float 数据点的缩放后值

:::callout{theme="success" title="另请参阅"} timestamp_scale()value_shift() :::

:::callout{theme="warning" title="注意"} 此函数仅适用于数值型序列(numeric series)。 :::

示例

>>> series = F.points(
...     (100, 0.0),
...     (200, float("inf")),
...     (300, 3.14159),
...     (2147483647, 1.0),
...     name="series"
... )
>>> series.to_pandas()
                      timestamp    value
0 1970-01-01 00:00:00.000000100  0.00000
1 1970-01-01 00:00:00.000000200      inf
2 1970-01-01 00:00:00.000000300  3.14159
3 1970-01-01 00:00:02.147483647  1.00000
>>> scaled = F.scale(1.5)(series)
>>> scaled.to_pandas()
                      timestamp     value
0 1970-01-01 00:00:00.000000100  0.000000
1 1970-01-01 00:00:00.000000200       inf
2 1970-01-01 00:00:00.000000300  4.712385
3 1970-01-01 00:00:02.147483647  1.500000