Time Primitives#
Classes that represent time anchors and time windows used throughout variable extraction. TimeAnchor wraps a column name and an optional offset; TimeWindow pairs a tmin and tmax anchor into a single object passed through the extraction pipeline.
- class corr_vars.utils.time.TimeAnchor(bound)[source]#
Bases:
object- Parameters:
bound (
str|tuple[str,str] |datetime|date|int)
- column: str | None#
- delta: str | None#
- expr: Expr#
- property is_relative: bool#
- property is_literal: bool#
- class corr_vars.utils.time.TimeWindow(tmin=None, tmax=None, user_specified=False)[source]#
Bases:
object- Parameters:
tmin (
TimeAnchor|str|tuple[str,str] |datetime|date|int|None)tmax (
TimeAnchor|str|tuple[str,str] |datetime|date|int|None)user_specified (
bool|tuple[bool,bool])
- tmin: TimeAnchor#
- tmax: TimeAnchor#
- user_specified_tmin: bool#
- user_specified_tmax: bool#
- property user_specified: bool#
- property tmin_expr: Expr#
- Parameters:
alias (
str)
- property tmax_expr: Expr#
- Parameters:
alias (
str)
- property tmid_expr: Expr#
- Parameters:
alias (
str)
- property duration_expr: Expr#
- Parameters:
alias (
str)
- property is_relative: bool#
- property is_literal: bool#
- property any_timebound_in_year_9999_expr: Expr#
- property any_timebound_null_expr: Expr#
- property tmin_after_tmax_expr: Expr#
- property any_timebound_invalid_expr: Expr#
- class corr_vars.utils.time.WindowRelation(value)[source]#
Bases:
Flag- CONTAINED = 1#
- OVERLAPS_LEFT = 2#
- OVERLAPS_RIGHT = 4#
- COVERS_WINDOW = 8#
- ANY_LEFT_OVERLAP = 11#
- ANY_RIGHT_OVERLAP = 13#
- ANY_OVERLAP = 15#
- class corr_vars.utils.time.WindowOverlap[source]#
Bases:
object- static contains_expr(record, window, closed='both')[source]#
- Parameters:
record (
TimeAnchor)window (
TimeWindow)closed (
Literal['left','right','both','none'])
- Return type:
Expr
- static relation_expr(record, window)[source]#
- Parameters:
record (
TimeWindow)window (
TimeWindow)
- Return type:
dict[WindowRelation,Expr]
- static overlap_expr(record, window, relation)[source]#
- Parameters:
record (
TimeWindow)window (
TimeWindow)relation (
WindowRelation)
- Return type:
Expr
- static classify_expr(record, window, *, default=None)[source]#
- Parameters:
record (
TimeWindow)window (
TimeWindow)default (
WindowRelation|None)
- Return type:
Expr
- corr_vars.utils.time.compatible_with_time_anchor(df, time_anchor)[source]#
- Parameters:
df (
DataFrame|LazyFrame)time_anchor (
TimeAnchor)
- Return type:
bool
- corr_vars.utils.time.compatible_with_time_window(df, time_window)[source]#
- Parameters:
df (
DataFrame|LazyFrame)time_window (
TimeWindow)
- Return type:
bool