pm4py.stats.get_case_duration#

pm4py.stats.get_case_duration(log: EventLog | DataFrame, case_id: str, business_hours: bool = False, business_hour_slots=[(25200, 61200), (111600, 147600), (198000, 234000), (284400, 320400), (370800, 406800)], activity_key: str = 'concept:name', timestamp_key: str = 'time:timestamp', case_id_key: str | None = None) float[source]#

Retrieves the duration of a specific case.

Return type:

float

Parameters:
  • log – Event log (EventLog or pandas DataFrame).

  • case_id (str) – Identifier of the case whose duration is to be retrieved.

  • business_hours (bool) – If True, computes duration based on business hours; otherwise, uses calendar time.

  • business_hour_slots

    Work schedule of the company as a list of tuples. Each tuple represents a time slot in seconds since the week start. Example: [

    (7 * 60 * 60, 17 * 60 * 60), ((24 + 7) * 60 * 60, (24 + 12) * 60 * 60), ((24 + 13) * 60 * 60, (24 + 17) * 60 * 60),

    ] This example means: - Monday 07:00 - 17:00 - Tuesday 07:00 - 12:00 - Tuesday 13:00 - 17:00

  • activity_key (str) – Attribute to be used for the activity.

  • timestamp_key (str) – Attribute to be used for the timestamp.

  • case_id_key – Attribute to be used as the case identifier.

Returns:

The duration of the specified case.

import pm4py

duration = pm4py.get_case_duration(
    dataframe,
    'case_1',
    activity_key='concept:name',
    case_id_key='case:concept:name',
    timestamp_key='time:timestamp'
)