time_windowed_features
time_windowed_features ¤
TimeWindowedFeatureTable ¤
TimeWindowedFeatureTable(
dataframe: DataFrame, time_column: str = "systime"
)
Bases: Base
Build ML-ready feature tables from segmented timeseries data.
Takes the output of SegmentProcessor.apply_ranges and computes statistical metrics per UUID within fixed-size time windows (e.g. every 1 minute).
Methods: - compute_long: One row per (time_window, uuid, segment). Long format. - compute: One row per time_window with columns {uuid}__{metric}. Wide format.
compute_long
classmethod
¤
compute_long(
dataframe: DataFrame,
window: str = "1min",
time_column: str = "systime",
uuid_column: str = "uuid",
value_column: str = "value_double",
segment_column: str | None = "segment_value",
metrics: list[str] | None = None,
) -> pd.DataFrame
Compute statistical metrics per UUID per time window (long format).
Groups the input data into fixed-size time windows of window and
computes numeric statistics for each (time_window, uuid, segment) group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame (typically output of SegmentProcessor.apply_ranges). |
required |
window
|
str
|
Pandas frequency string for the time window size (e.g.
'1min', '30s', '5min'). |
'1min'
|
time_column
|
str
|
Column containing timestamps. |
'systime'
|
uuid_column
|
str
|
Column identifying each timeseries signal. |
'uuid'
|
value_column
|
str
|
Column containing numeric values. |
'value_double'
|
segment_column
|
str | None
|
Column to sub-group by (e.g. 'segment_value'). Set to None to ignore segments entirely. |
'segment_value'
|
metrics
|
list[str] | None
|
Subset of metric names to compute. None uses all 19. |
None
|
Windows are the bins of pd.Grouper(freq=window) (for sub-daily
frequencies they start at midnight of the first day; on tz-aware data
they are wall-clock windows in the data's zone). A window that spans a
segment change gives one row per segment. Groups with fewer than 2
non-missing values are left out.
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns [time_window, uuid, segment_value?, |
DataFrame
|
sample_count, metric_1, ..., start, end, duration_seconds], one row |
DataFrame
|
per (window, uuid, segment) sorted in that order. |
DataFrame
|
window start (= |
DataFrame
|
Empty (with these columns) when no group has 2 values. |
compute
classmethod
¤
compute(
dataframe: DataFrame,
window: str = "1min",
time_column: str = "systime",
uuid_column: str = "uuid",
value_column: str = "value_double",
segment_column: str | None = "segment_value",
metrics: list[str] | None = None,
column_separator: str = "__",
) -> pd.DataFrame
Compute a wide-format feature table with one row per time window.
Each column is named {uuid}{separator}{metric} (e.g.
temperature__mean). Windows where a UUID has insufficient data
are filled with NaN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame (typically output of SegmentProcessor.apply_ranges). |
required |
window
|
str
|
Pandas frequency string for the time window size.
|
'1min'
|
time_column
|
str
|
Column containing timestamps. |
'systime'
|
uuid_column
|
str
|
Column identifying each timeseries signal. |
'uuid'
|
value_column
|
str
|
Column containing numeric values. |
'value_double'
|
segment_column
|
str | None
|
Column to sub-group by. Set to None to ignore segments. |
'segment_value'
|
metrics
|
list[str] | None
|
Subset of metric names to compute. None uses all 19. |
None
|
column_separator
|
str
|
Separator between uuid and metric in wide column names. |
'__'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns [time_window, segment_value?, {uuid}__{metric}, ...]. |