Skip to content

ocel

ocel ¤

OCEL 2.0–shaped exporter — returns the relational tables.

ts-shape does not write OCEL JSON or SQLite itself; users feed these DataFrames to pm4py (or any other OCEL tool) directly. The column names match the OCEL 2.0 spec verbatim. pm4py additionally expects the event activity / timestamp on every E2O relation and a wide object_changes table (the new value in a column named after ocel:field); pass pm4py=True to get exactly that layout, which maps straight onto pm4py's OCEL constructor and its OCEL 2.0 JSON / XML / SQLite writers::

t = to_event_log_ocel(log, pm4py=True)
ocel = pm4py.objects.ocel.obj.OCEL(
    events=t.events, objects=t.objects, relations=t.relations,
    o2o=t.o2o, object_changes=t.object_changes,
)

OCEL2Tables dataclass ¤

OCEL2Tables(
    events: DataFrame,
    objects: DataFrame,
    relations: DataFrame,
    o2o: DataFrame,
    object_changes: DataFrame,
)

The five OCEL 2.0 relational tables produced from an :class:EventLog.

to_event_log_ocel ¤

to_event_log_ocel(
    eventlog: EventLog, *, pm4py: bool = False
) -> OCEL2Tables

Return the OCEL 2.0 tables as an :class:OCEL2Tables bundle.

The canonical schema already uses OCEL 2.0 column names, so by default this is a pass-through with defensive copy() calls to prevent caller mutation.

With pm4py=True two tables are reshaped for pm4py's OCEL object: relations gains ocel:activity and ocel:timestamp of each event, and object_changes is widened — ocel:value is replaced by one column per distinct ocel:field holding the new value on that field's rows (a field named like a base column, e.g. ocel:type, gets the column <name>_field and a :class:~ts_shape.errors.DataQualityWarning). The other tables are unchanged.

Parameters:

Name Type Description Default
eventlog EventLog

The event log to export.

required
pm4py bool

Reshape relations and object_changes for pm4py.

False

Returns:

Type Description
OCEL2Tables

The five tables as :class:OCEL2Tables (copies).