Skip to content
v0.2.1

Events Manager

class EventsManager(BaseManager):

Manages event-level information within an OCEL instance.

Provides access to:

  • the events table
  • event activities and activity counts
  • activity lookup by event ID
  • event attribute names
  • structured summaries of event attributes

Acts as a facade over the underlying PM4PY OCEL object.

Source
class EventsManager(BaseManager):
"""
Manages event-level information within an OCEL instance.
Provides access to:
- the events table
- event activities and activity counts
- activity lookup by event ID
- event attribute names
- structured summaries of event attributes
Acts as a facade over the underlying PM4PY OCEL object.
"""
@property
def df(self) -> pd.DataFrame:
"""
Return the event table from the underlying OCEL.
Returns:
DataFrame: A pandas DataFrame containing all events and their attributes.
"""
return self._ocel.ocel.events
@property
@instance_lru_cache()
def activities(self) -> list[str]:
"""
Return all activity names present in the log.
Returns:
list[str]: A sorted list of unique activity names.
"""
return list(sorted(self.df[ACTIVITY_COL].unique().tolist()))
@property
@instance_lru_cache()
def activity_counts(self) -> pd.Series:
"""
Return the frequency of each activity in the log.
Returns:
Series: A pandas Series indexed by activity name with occurrence counts.
"""
return self.df[ACTIVITY_COL].value_counts()
@property
@instance_lru_cache()
def activity_by_id(self) -> pd.Series:
"""
Return a mapping from event ID to activity.
Returns:
Series: A pandas Series indexed by event ID, containing activity names as values.
"""
return cast(pd.Series, self.df[[EID_COL, ACTIVITY_COL]].set_index(EID_COL)[ACTIVITY_COL])
@property
def attribute_names(self) -> list[str]:
"""
Return the names of all event attributes.
Returns:
list[str]: A sorted list of event attribute names.
"""
return sorted([col for col in self.df.columns if not col.startswith("ocel:")])
@property
@instance_lru_cache()
def attribute_summary(self) -> pd.DataFrame:
"""Return an attribute summary for events, grouped by activity.
RETURNS:
A pandas DataFrame indexed by (ATTRIBUTE_COL, ACTIVITY_COL) containing
the summary statistics produced by `get_summary`.
"""
return self._ocel.attributes.get_activity_summary()
def get_event_timestamp(self, event_id: str):
"""
Returns the timestamp of the passed event.
"""
return str(self.df.loc[self.df[EID_COL].eq(event_id), TIMESTAMP_COL].iloc[0])
df: pd.DataFrame

Return the event table from the underlying OCEL.

Returns:

  • pd.DataFrame — A pandas DataFrame containing all events and their attributes.
activities: list[str]

Return all activity names present in the log.

Returns:

  • list[str] — list[str]: A sorted list of unique activity names.
activity_counts: pd.Series

Return the frequency of each activity in the log.

Returns:

  • pd.Series — A pandas Series indexed by activity name with occurrence counts.
activity_by_id: pd.Series

Return a mapping from event ID to activity.

Returns:

  • pd.Series — A pandas Series indexed by event ID, containing activity names as values.
attribute_names: list[str]

Return the names of all event attributes.

Returns:

  • list[str] — list[str]: A sorted list of event attribute names.
attribute_summary: pd.DataFrame

Return an attribute summary for events, grouped by activity.

Returns:

  • pd.DataFrame — A pandas DataFrame indexed by (ATTRIBUTE_COL, ACTIVITY_COL) containing
  • pd.DataFrame — the summary statistics produced by get_summary.
def get_event_timestamp(event_id: str):

Returns the timestamp of the passed event.

Source
def get_event_timestamp(self, event_id: str):
"""
Returns the timestamp of the passed event.
"""
return str(self.df.loc[self.df[EID_COL].eq(event_id), TIMESTAMP_COL].iloc[0])