跳转至

foundryts.functions.skip_nonfinite

foundryts.functions.skip_nonfinite()

Returns a function that filters all points with non-finite values in a time series.

Non-finite values can be inf or NaN.

  • Returns: A function that accepts a single time series and returns the filtered time series with only finite point 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"} where() :::

Examples

>>> series = F.points(
...     (100, 100.0),
...     (120, float("nan")),
...     (130, 230.0),
...     (166, float("inf")),
...     (167, 366.0),
...     (168, float("-inf")),
...     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    NaN
2 1970-01-01 00:00:00.000000130  230.0
3 1970-01-01 00:00:00.000000166    inf
4 1970-01-01 00:00:00.000000167  366.0
5 1970-01-01 00:00:00.000000168   -inf
>>> finite_series = F.skip_nonfinite()(series)
>>> finite_series.to_pandas()
                      timestamp  value
0 1970-01-01 00:00:00.000000100  100.0
1 1970-01-01 00:00:00.000000130  230.0
2 1970-01-01 00:00:00.000000167  366.0

中文翻译

foundryts.functions.skip_nonfinite

foundryts.functions.skip_nonfinite()

返回一个函数,用于过滤时间序列中所有非有限值的点。

非有限值可以是 infNaN

  • 返回值: 一个接受单个时间序列并返回仅包含有限点值的过滤后时间序列的函数。
  • 返回类型: (FunctionNode) -> FunctionNode

Dataframe 模式

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

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

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

示例

>>> series = F.points(
...     (100, 100.0),
...     (120, float("nan")),
...     (130, 230.0),
...     (166, float("inf")),
...     (167, 366.0),
...     (168, float("-inf")),
...     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    NaN
2 1970-01-01 00:00:00.000000130  230.0
3 1970-01-01 00:00:00.000000166    inf
4 1970-01-01 00:00:00.000000167  366.0
5 1970-01-01 00:00:00.000000168   -inf
>>> finite_series = F.skip_nonfinite()(series)
>>> finite_series.to_pandas()
                      timestamp  value
0 1970-01-01 00:00:00.000000100  100.0
1 1970-01-01 00:00:00.000000130  230.0
2 1970-01-01 00:00:00.000000167  366.0