pm4py.algo.filtering.pandas.timestamp.timestamp_filter module#
PM4Py – A Process Mining Library for Python Copyright (C) 2026 Process Intelligence Solutions GmbH
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see this software project’s root or visit <https://www.gnu.org/licenses/>.
Website: https://processintelligence.solutions Contact: info@processintelligence.solutions
- class pm4py.algo.filtering.pandas.timestamp.timestamp_filter.Parameters(*values)[source]#
Bases:
Enum- TIMESTAMP_KEY = 'pm4py:param:timestamp_key'#
- CASE_ID_KEY = 'pm4py:param:case_id_key'#
- KEEP_NAN_VALUES = 'keep_nan_values'#
- pm4py.algo.filtering.pandas.timestamp.timestamp_filter.filter_traces_contained(df: DataFrame, dt1: str | datetime, dt2: str | datetime, parameters: Dict[str | Parameters, Any] | None = None) DataFrame[source]#
Get traces that are contained in the given interval
- Parameters:
df – Pandas dataframe
dt1 – Lower bound to the interval (possibly expressed as string, but automatically converted)
dt2 – Upper bound to the interval (possibly expressed as string, but automatically converted)
parameters –
- Possible parameters of the algorithm, including:
Parameters.TIMESTAMP_KEY -> Attribute to use as timestamp Parameters.CASE_ID_KEY -> Column that contains the timestamp Parameters.KEEP_NAN_VALUES -> If true, keeps traces which do not contain any event with temporal data for the selected attribute. Default is false
- Returns:
Filtered dataframe
- Return type:
df
- pm4py.algo.filtering.pandas.timestamp.timestamp_filter.filter_traces_intersecting(df: DataFrame, dt1: str | datetime, dt2: str | datetime, parameters: Dict[str | Parameters, Any] | None = None) DataFrame[source]#
Filter traces intersecting the given interval
- Parameters:
df – Pandas dataframe
dt1 – Lower bound to the interval (possibly expressed as string, but automatically converted)
dt2 – Upper bound to the interval (possibly expressed as string, but automatically converted)
parameters –
- Possible parameters of the algorithm, including:
Parameters.TIMESTAMP_KEY -> Attribute to use as timestamp Parameters.CASE_ID_KEY -> Column that contains the timestamp Parameters.KEEP_NAN_VALUES -> If true, keeps traces which do not contain any event with data for the selected timestamp attribute. Default is false
- Returns:
Filtered dataframe
- Return type:
df
- pm4py.algo.filtering.pandas.timestamp.timestamp_filter.apply_events(df: DataFrame, dt1: str | datetime, dt2: str | datetime, parameters: Dict[str | Parameters, Any] | None = None) DataFrame[source]#
Get a new log containing all the events contained in the given interval
- Parameters:
df – Pandas dataframe
dt1 – Lower bound to the interval (possibly expressed as string, but automatically converted)
dt2 – Upper bound to the interval (possibly expressed as string, but automatically converted)
parameters –
- Possible parameters of the algorithm, including:
Parameters.TIMESTAMP_KEY -> Attribute to use as timestamp Parameters.KEEP_NAN_VALUES -> If true, keeps events which do not contain temporal data for the selected attribute. Default is false
- Returns:
Filtered dataframe
- Return type:
df
- pm4py.algo.filtering.pandas.timestamp.timestamp_filter.filter_traces_attribute_in_timeframe(df: DataFrame, attribute: str, attribute_value: str, dt1: str | datetime, dt2: str | datetime, parameters: Dict[str | Parameters, Any] | None = None) DataFrame[source]#
Get a new log containing all the traces that have an event in the given interval with the specified attribute value
- Parameters:
df – Dataframe
attribute – The attribute to filter on
attribute_value – The attribute value to filter on
dt1 – Lower bound to the interval
dt2 – Upper bound to the interval
parameters –
- Possible parameters of the algorithm, including:
Parameters.TIMESTAMP_KEY -> Attribute to use as timestamp Parameters.KEEP_NAN_VALUES -> If true, keeps traces which do not contain any event with temporal data for the selected attribute. Default is false
- Returns:
Filtered dataframe
- Return type:
df
- pm4py.algo.filtering.pandas.timestamp.timestamp_filter.filter_traces_starting_in_timeframe(df: DataFrame, dt1: str | datetime, dt2: str | datetime, parameters: Dict[str | Parameters, Any] | None = None) DataFrame[source]#
Keep/Exclude traces whose first event timestamp falls in [dt1, dt2].
- Parameters:
df – Pandas dataframe
dt1 – Lower bound to the interval (string or datetime)
dt2 – Upper bound to the interval (string or datetime)
parameters –
- Possible parameters of the algorithm, including:
Parameters.TIMESTAMP_KEY -> Attribute to use as timestamp Parameters.CASE_ID_KEY -> Column that contains the case id “positive” (bool, default True) -> keep (True) or exclude (False) the matching cases Parameters.KEEP_NAN_VALUES -> If true, keeps traces which do not contain any event with temporal data for the selected attribute. Default is false
- Returns:
Filtered dataframe (all events for the selected cases)
- Return type:
df
- pm4py.algo.filtering.pandas.timestamp.timestamp_filter.filter_traces_completing_in_timeframe(df: DataFrame, dt1: str | datetime, dt2: str | datetime, parameters: Dict[str | Parameters, Any] | None = None) DataFrame[source]#
Keep/Exclude traces whose last event timestamp falls in [dt1, dt2].
- Parameters:
df – Pandas dataframe
dt1 – Lower bound to the interval (string or datetime)
dt2 – Upper bound to the interval (string or datetime)
parameters –
- Possible parameters of the algorithm, including:
Parameters.TIMESTAMP_KEY -> Attribute to use as timestamp Parameters.CASE_ID_KEY -> Column that contains the case id “positive” (bool, default True) -> keep (True) or exclude (False) the matching cases Parameters.KEEP_NAN_VALUES -> If true, keeps traces which do not contain any event with temporal data for the selected attribute. Default is false
- Returns:
Filtered dataframe (all events for the selected cases)
- Return type:
df