TimeFrame

class time_stream.TimeFrame(df, time_name, resolution=None, periodicity=None, time_anchor=TimeAnchor.START, on_duplicates=DuplicateOption.ERROR)[source]

A class representing a time series data model, with data held in a Polars DataFrame.

Parameters:
  • df (DataFrame) – The Polars DataFrame containing the time series data.

  • time_name (str) – The name of the time column in the DataFrame.

  • resolution (Period | str | None) – The resolution of the time series.

  • periodicity (Period | str | None) – The periodicity of the time series.

  • time_anchor (TimeAnchor | str) – The time anchor to which the date/times of the time series conform to.

  • on_duplicates (DuplicateOption | str) – What to do if duplicate rows are found in the data. Default to ERROR.

Attributes

resolution

The resolution of the timeseries data within the TimeFrame

periodicity

The periodicity of the timeseries data within the TimeFrame

time_anchor

The time anchor of the timeseries data within the TimeFrame

time_name

The name of the primary datetime column in the underlying TimeFrame DataFrame.

columns

All column labels of the DataFrame within the TimeFrame.

flag_columns

Only the labels for any flag columns within the TimeFrame.

data_columns

Only the labels for the data columns within the TimeFrame.

metadata

TimeFrame-level metadata.

column_metadata

Per-column metadata.

df

The underlying Polars DataFrame containing the timeseries data.

Methods

Builders

with_df

Return a new TimeFrame with a new DataFrame, checking the integrity of the time values hasn't been compromised between the old and new TimeFrame.

with_metadata

Return a new TimeFrame with TimeFrame-level metadata.

with_column_metadata

Return a new TimeFrame with column-level metadata.

with_flag_system

Return a new TimeFrame, with a flag system registered.

General

sort_time

Sort the TimeFrame DataFrame by the time column.

pad

Pad the time series with missing datetime rows, filling in NULLs for missing values.

select

Return a new TimeFrame instance to include only the specified columns.

Operations

aggregate

Apply an aggregation function to a column in this TimeFrame, check the aggregation satisfies user requirements and return a new derived TimeFrame containing the aggregated data.

infill

Apply an infilling method to a column in the TimeFrame to fill in missing data.

qc_check

Apply a quality control check to the TimeFrame.

Flagging

register_flag_system

Register a named flag system with the internal flag manager.

get_flag_system

Return a registered flag system.

register_flag_column

Mark the specified existing column as a flag column.

init_flag_column

Add a new column to the TimeFrame DataFrame, setting it as a Flag Column.

get_flag_column

Look up a registered flag column by name.

add_flag

Add flag value (if not there) to flag column, where expression is True.

remove_flag

Remove flag value (if there) from flag column.