[docs]classCumSum(Stream[float]):"""A stream operator that creates a cumulative sum of values. References ---------- .. [1] https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.cumsum.html """def__init__(self)->None:super().__init__()self.c_sum=0
[docs]classCumMin(Stream[float]):"""A stream operator that creates a cumulative minimum of values. Parameters ---------- skip_na : bool, default True Exclude NA/null values. If a value is NA, the result will be NA. References ---------- [1] https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.cummin.html """def__init__(self,skip_na:bool=True)->None:super().__init__()self.skip_na=skip_naself.c_min=np.inf
[docs]classCumMax(Stream[float]):"""A stream operator that creates a cumulative maximum of values. Parameters ---------- skip_na : bool, default True Exclude NA/null values. If a value is NA, the result will be NA. References ---------- [1] https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.cummax.html """def__init__(self,skip_na:bool=True)->None:super().__init__()self.skip_na=skip_naself.c_max=-np.inf
[docs]@Float.register(["cumsum"])defcumsum(s:"Stream[float]")->"Stream[float]":"""Computes the cumulative sum of a stream. Parameters ---------- s : `Stream[float]` A float stream. Returns ------- `Stream[float]` The cumulative sum stream of `s`. """returnCumSum()(s).astype("float")
[docs]@Float.register(["cumprod"])defcumprod(s:"Stream[float]")->"Stream[float]":"""Computes the cumulative product of a stream. Parameters ---------- s : `Stream[float]` A float stream. Returns ------- `Stream[float]` The cumulative product stream of `s`. """returnCumProd()(s).astype("float")
[docs]@Float.register(["cummin"])defcummin(s:"Stream[float]",skipna:bool=True)->"Stream[float]":"""Computes the cumulative minimum of a stream. Parameters ---------- s : `Stream[float]` A float stream. skipna : bool, default True Exclude NA/null values. If a value is NA, the result will be NA. Returns ------- `Stream[float]` The cumulative minimum stream of `s`. """returnCumMin(skip_na=skipna)(s).astype("float")
[docs]@Float.register(["cummax"])defcummax(s:"Stream[float]",skipna:bool=True)->"Stream[float]":"""Computes the cumulative maximum of a stream. Parameters ---------- s : `Stream[float]` A float stream. skipna : bool, default True Exclude NA/null values. If a value is NA, the result will be NA. Returns ------- `Stream[float]` The cumulative maximum stream of `s`. """returnCumMax(skip_na=skipna)(s).astype("float")