Events Manager
class EventsManager
Section titled “class EventsManager”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])attribute df
Section titled “attribute df”df: pd.DataFrameReturn the event table from the underlying OCEL.
Returns:
pd.DataFrame— A pandas DataFrame containing all events and their attributes.
attribute activities
Section titled “attribute activities”activities: list[str]Return all activity names present in the log.
Returns:
list[str]— list[str]: A sorted list of unique activity names.
attribute activity_counts
Section titled “attribute activity_counts”activity_counts: pd.SeriesReturn the frequency of each activity in the log.
Returns:
pd.Series— A pandas Series indexed by activity name with occurrence counts.
attribute activity_by_id
Section titled “attribute activity_by_id”activity_by_id: pd.SeriesReturn a mapping from event ID to activity.
Returns:
pd.Series— A pandas Series indexed by event ID, containing activity names as values.
attribute attribute_names
Section titled “attribute attribute_names”attribute_names: list[str]Return the names of all event attributes.
Returns:
list[str]— list[str]: A sorted list of event attribute names.
attribute attribute_summary
Section titled “attribute attribute_summary”attribute_summary: pd.DataFrameReturn an attribute summary for events, grouped by activity.
Returns:
pd.DataFrame— A pandas DataFrame indexed by (ATTRIBUTE_COL, ACTIVITY_COL) containingpd.DataFrame— the summary statistics produced byget_summary.
function get_event_timestamp
Section titled “function get_event_timestamp”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])