Skip to content

Temporal Grouping

lazymerge.TemporalGrouper

Bases: ABC

datetime_filter abstractmethod

datetime_filter(group_key: str) -> tuple[str, str]

Return (start, end) datetime range for SQL filtering. End is exclusive.

group_key abstractmethod

group_key(datetime_str: str) -> str

Map an RFC 3339 datetime string to a sortable group label.

to_datetime64 abstractmethod

to_datetime64(group_key: str) -> datetime64

Produce a datetime64[D] coordinate value for the group.

lazymerge.grouper_from_period

grouper_from_period(period: str) -> TemporalGrouper

Parse an ISO 8601 duration string and return the appropriate grouper.

Supported formats: P1D, P1W, P1M, P1Y, PnD (n >= 2), PnW (converted to n*7 day fixed window).