Skip to content

Commit

Permalink
添加ts_cum_count
Browse files Browse the repository at this point in the history
  • Loading branch information
wukan1986 committed Dec 22, 2024
1 parent ae7ff95 commit 4e0113d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion polars_ta/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.2"
__version__ = "0.4.3"
9 changes: 7 additions & 2 deletions polars_ta/wq/time_series.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import polars_ols as pls
from polars import Expr, Int32, UInt16, struct, when, Struct, Field, Float64
from polars import Expr, UInt16, struct, when, Struct, Field, Float64, Boolean
from polars import arange, repeat
from polars import rolling_corr, rolling_cov
from polars_ols import RollingKwargs
Expand Down Expand Up @@ -109,7 +109,7 @@ def ts_corr(x: Expr, y: Expr, d: int = 5, ddof: int = 1) -> Expr:

def ts_count(x: Expr, d: int = 30) -> Expr:
"""时序滚动计数"""
return x.cast(Int32).rolling_sum(d)
return x.cast(Boolean).rolling_sum(d)


def ts_count_nans(x: Expr, d: int = 5) -> Expr:
Expand Down Expand Up @@ -143,6 +143,11 @@ def ts_covariance(x: Expr, y: Expr, d: int = 5, ddof: int = 1) -> Expr:
return rolling_cov(x, y, window_size=d, ddof=ddof)


def ts_cum_count(x: Expr) -> Expr:
"""时序累计计数"""
return x.cum_count()


def ts_cum_max(x: Expr) -> Expr:
"""时序累计最大"""
return x.cum_max()
Expand Down

0 comments on commit 4e0113d

Please sign in to comment.