ts_shape.utils.base
Base class and architecture guidelines for ts-shape.
ts-shape uses two complementary patterns for data processing. Choose the right one based on the complexity of the operation:
Stateless classmethods — use when:
- The operation is a single, self-contained transformation (filter, calculate, convert, aggregate).
- There is no shared configuration between methods.
- The result depends only on the inputs (pure function).
- Examples:
IntegerCalc,StringFilter,NumericStatistics,DateTimeFilter,LambdaProcessor.
Stateful instance classes — use when:
- Multiple related methods share configuration (column names, signal UUIDs, thresholds, tolerances).
- The constructor validates or preprocesses data once for many operations (e.g. sorting, filtering to a specific UUID).
- The domain workflow has a natural setup phase before analysis (e.g. compute control limits, then apply SPC rules).
- Examples:
DataHarmonizer,OutlierDetectionEvents,MachineStateEvents,OEEEvents, all event classes.
Pipeline — use when chaining multiple steps:
- Chains transforms (
.transform()) and detectors (.detect()) into one reusable definition; works with both class patterns above and plain callables. - Supports
$prev/$inputsentinels for multi-DataFrame wiring andrun_steps()for intermediate-result capture. - See
ts_shape.pipeline.
Classes
| Name | Description |
|---|---|
Base |
Base
Base(dataframe: pd.DataFrame, time_column: str = 'systime') -> None
Functions
| Name | Description |
|---|---|
get_dataframe | Returns the processed DataFrame. |
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Long-format input (systime, uuid, value_*). | required |
time_column | str | Timestamp column to convert and sort by. When it is missing, datetime or text columns whose name contains "time" or "date" are read as timestamps instead (with a :class:~ts_shape.errors.DataQualityWarning); numeric columns are never converted. | 'systime' |
Raises
| Type | Description |
|---|---|
TypeError | If dataframe is not a pandas DataFrame. |
ColumnNotFoundError | For a detector (ts_shape.events), if a non-empty dataframe has no time_column. |
get_dataframe
get_dataframe() -> pd.DataFrame
Returns the processed DataFrame.
A detector that keeps only its own signals' rows (see
_keep_signal_rows) builds the whole processed frame on the first
call, from the input it was given.