跳转至

foundryts.functions.last_point

foundryts.functions.last_point()

Returns a function that extracts the latest point for a single time series.

The returned point is the last occuring point within the range of a given time series. Returns an empty summary when the series is empty.

  • Returns: A function that accepts a single time series and returns the last point in the provided series. The dataframe contains a single row with the last point.
  • Return type: (FunctionNode) -> SummarizerNode

Dataframe schema

Column name Type Description
timestamp pandas.Timestamp Timestamp of the point
value Union[float, str] Value of the point

:::callout{theme="success" title="See Also"} time_extent(), first_point() :::

Examples

>>> series = F.points(
...     (1, 0.0),
...     (101, 10.2),
...     (200, 11.3),
...     (123450, 11.8),
... )
>>> series.to_pandas()
                      timestamp  value
0 1970-01-01 00:00:00.000000001    0.0
1 1970-01-01 00:00:00.000000101   10.2
2 1970-01-01 00:00:00.000000200   11.3
3 1970-01-01 00:00:00.000123450   11.8
>>> lp = F.last_point()(series)
>>> lp.to_pandas()
                      timestamp  value
0 1970-01-01 00:00:00.000123450   11.8

中文翻译


foundryts.functions.last_point

foundryts.functions.last_point()

返回一个函数,用于提取单个时间序列(time series)中的最新数据点。

返回的数据点是给定时间序列范围内最后一个出现的数据点。当序列为空时,返回空摘要。

  • 返回值: 一个函数,接受单个时间序列作为输入,并返回该序列中的最后一个数据点。返回的数据框(dataframe)包含一行,即最后一个数据点。
  • 返回类型: (FunctionNode) -> SummarizerNode

数据框模式(Dataframe schema)

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

:::callout{theme="success" title="另请参阅"} time_extent(), first_point() :::

示例

>>> series = F.points(
...     (1, 0.0),
...     (101, 10.2),
...     (200, 11.3),
...     (123450, 11.8),
... )
>>> series.to_pandas()
                      timestamp  value
0 1970-01-01 00:00:00.000000001    0.0
1 1970-01-01 00:00:00.000000101   10.2
2 1970-01-01 00:00:00.000000200   11.3
3 1970-01-01 00:00:00.000123450   11.8
>>> lp = F.last_point()(series)
>>> lp.to_pandas()
                      timestamp  value
0 1970-01-01 00:00:00.000123450   11.8