跳转至

foundryts.functions.derivative

foundryts.functions.derivative()

Returns a function that calculates the per-second value change for a single time series.

For every point in the time series, starting from the second point, output a tick with the derivative of the value of the previous point in time. Each value is scaled to a per-second rate irrespective of the original frequency at which the ticks are stored.

  • Returns: A function that accepts a single time series as input and returns a time series with per-second derative values.
  • Return type: (FunctionNode) -> FunctionNode

Dataframe schema

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

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

:::callout{theme="success" title="See Also"} integral() :::

Examples

>>> series = F.points(
...     (100, 100.0), (120, 200.0), (130, 230.0), (166, 266.0), (167, 366.0), name="series"
... )
>>> series.to_pandas()
                      timestamp  value
0 1970-01-01 00:00:00.000000100  100.0
1 1970-01-01 00:00:00.000000120  200.0
2 1970-01-01 00:00:00.000000130  230.0
3 1970-01-01 00:00:00.000000166  266.0
4 1970-01-01 00:00:00.000000167  366.0
>>> derivative_series = F.derivative()(series)
>>> derivative_series.to_pandas()
                      timestamp         value
0 1970-01-01 00:00:00.000000120  5.000000e+09
1 1970-01-01 00:00:00.000000130  3.000000e+09
2 1970-01-01 00:00:00.000000166  1.000000e+09
3 1970-01-01 00:00:00.000000167  1.000000e+11

中文翻译


foundryts.functions.derivative

foundryts.functions.derivative()

返回一个函数,用于计算单个时间序列的每秒值变化。

对于时间序列中的每个点(从第二个点开始),输出一个包含前一个时间点值导数的数据点。每个值都会缩放为每秒速率,无论原始数据点的存储频率如何。

  • 返回值: 一个接受单个时间序列作为输入,并返回包含每秒导数值的时间序列的函数。
  • 返回类型: (FunctionNode) -> FunctionNode

数据框模式(Dataframe schema)

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

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

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

示例

>>> series = F.points(
...     (100, 100.0), (120, 200.0), (130, 230.0), (166, 266.0), (167, 366.0), name="series"
... )
>>> series.to_pandas()
                      timestamp  value
0 1970-01-01 00:00:00.000000100  100.0
1 1970-01-01 00:00:00.000000120  200.0
2 1970-01-01 00:00:00.000000130  230.0
3 1970-01-01 00:00:00.000000166  266.0
4 1970-01-01 00:00:00.000000167  366.0
>>> derivative_series = F.derivative()(series)
>>> derivative_series.to_pandas()
                      timestamp         value
0 1970-01-01 00:00:00.000000120  5.000000e+09
1 1970-01-01 00:00:00.000000130  3.000000e+09
2 1970-01-01 00:00:00.000000166  1.000000e+09
3 1970-01-01 00:00:00.000000167  1.000000e+11