Skip to main content
Version: Next

ts_shape.eventlog.normalizer

Public to_event_log entry point — looks up the adapter and runs it.

Functions
NameDescription
to_event_logNormalize a detector frame (a detector's output DataFrame) into the

to_event_log​

functionsource
to_event_log(
dataframe: pd.DataFrame,
*,
detector: str,
objects: Mapping[str, object] | None = None,
qualifiers: Mapping[str, str] | None = None,
o2o: TableInput = None,
object_changes: TableInput = None,
validate: bool = True,
timestamp: object | None = None
) -> EventLog

Normalize a detector frame (a detector's output DataFrame) into the canonical event log.

Timestamps: tz-aware times are converted to UTC; naive times are taken to be UTC (localize them first if they are local wall-clock times). Interval rows that end before they start are dropped with a :class:~ts_shape.errors.DataQualityWarning.

Event ids (ocel:eid) are content-based: a hash of the detector, the row's source_uuid, its timestamps, the activity, every other column of the row and the objects bound with objects= (so one row bound to asset M1 and to M2 gives two events). They are reproducible across runs, independent of row order, and the same detector on two machines does not collide. Rows without an ocel:timestamp (a missing systime, or end for interval and summary detectors) are dropped with a :class:~ts_shape.errors.DataQualityWarning.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameThe detector frame.required
detectorstr"ClassName.method_name" -- the key used in the taxonomy registry and the value written to ts_shape:detector. Deprecated names resolve to the current ones.required
objectsMapping[str, object] | NoneBinds OCEL object types to, per type:
* a column name of dataframe (e.g. {"asset": "source_uuid"}); * any other string or scalar -- a literal broadcast to every row ({"line": "L1"}); None binds no object; * a callable taking a row dict and returning an oid; * a pd.Series aligned with dataframe by index label (a length or label mismatch raises ValueError).
Types listed in the rule's produces_objects are also auto-extracted from standard columns (source_uuid -> asset) when not bound explicitly.
None
qualifiersMapping[str, str] | NoneRelation qualifier per object type.None
o2oTableInputOCEL 2.0 object-to-object relations, a DataFrame or iterable of dict rows with ocel:oid / ocel:oid_2 (ocel:qualifier optional); see :func:~ts_shape.eventlog.schema.empty_o2o.None
object_changesTableInputTime-varying object attributes with ocel:oid, ocel:type, ocel:field, ocel:timestamp (ocel:value optional); see :func:~ts_shape.eventlog.schema.empty_object_changes. Naive timestamps are read as UTC.None
validateboolCheck the result against the canonical schema.True
timestampobject | NoneTimestamp of the events of a static shape detector (which has no time column). Default: the Unix epoch (1970-01-01T00:00Z), so results are reproducible.None
Returns
TypeDescription
EventLogThe canonical :class:~ts_shape.eventlog.model.EventLog.
Raises
TypeDescription
ValueErrorFor a malformed detector name, a misaligned Series binding or a table missing required columns.
KeyErrorWhen the detector has no taxonomy entry, or the frame lacks the time columns of its shape.