pm4py.ml.get_prefixes_from_log#

pm4py.ml.get_prefixes_from_log(log: EventLog | DataFrame, length: int, case_id_key: str = 'case:concept:name') EventLog | DataFrame[source]#

Retrieves prefixes of traces in a log up to a specified length.

The returned log contains prefixes of each trace: - If a trace has a length less than or equal to the specified length, it is included as-is. - If a trace exceeds the specified length, it is truncated to that length.

Parameters:
  • log – The event log or Pandas DataFrame from which to extract prefixes.

  • length (int) – The maximum length of prefixes to extract.

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

Returns:

A log containing the prefixes of the original log.

Return type:

Union[EventLog, pd.DataFrame]

import pm4py

trimmed_df = pm4py.get_prefixes_from_log(dataframe, length=5, case_id_key='case:concept:name')