Skip to main content
Version: Next

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 / $input sentinels for multi-DataFrame wiring and run_steps() for intermediate-result capture.
  • See ts_shape.pipeline.
Classes
NameDescription
Base

Base​

classsource
Base(dataframe: pd.DataFrame, time_column: str = 'systime') -> None
Functions
NameDescription
get_dataframeReturns the processed DataFrame.
Parameters
NameTypeDescriptionDefault
dataframeDataFrameLong-format input (systime, uuid, value_*).required
time_columnstrTimestamp 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
TypeDescription
TypeErrorIf dataframe is not a pandas DataFrame.
ColumnNotFoundErrorFor a detector (ts_shape.events), if a non-empty dataframe has no time_column.

get_dataframe​

methodsource
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.