Skip to content

flat

flat ¤

XES-flat exporter — produces a pandas DataFrame with case:concept:name, concept:name, time:timestamp, lifecycle:transition, org:resource columns. ts-shape itself does not import pm4py; users pass this DataFrame to pm4py.format_dataframe themselves.

to_event_log_xes ¤

to_event_log_xes(
    eventlog: EventLog,
    *,
    case_object_type: str = "asset",
    lifecycle: str = "single"
) -> pd.DataFrame

Flatten the event log into an XES-style DataFrame.

A trace is built per object of case_object_type — each event linked to that object becomes one (or two) rows in the trace.

lifecycle="single" — interval events become one row with lifecycle:transition="complete". time:timestamp is the interval-end; start_timestamp is exposed verbatim.

lifecycle="two_row" — interval events expand into a start row (using ts_shape:start_timestamp) and a complete row, paired by concept:instance.

Parameters:

Name Type Description Default
eventlog EventLog

The event log to flatten.

required
case_object_type str

Object type whose objects become the traces.

'asset'
lifecycle str

"single" or "two_row".

'single'

Returns:

Type Description
DataFrame

DataFrame with case:concept:name, concept:name,

DataFrame

time:timestamp, lifecycle:transition (and org:resource

DataFrame

when the log links operators), sorted by case and time.

Raises:

Type Description
ValueError

When the log has no objects, no object of case_object_type, or lifecycle is unknown.