pm4py.objects.log.util.dataframe_utils 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.objects.log.util.dataframe_utils.Parameters(*values)[source]#

Bases: Enum

PARTITION_COLUMN = 'partition_column'#
CASE_ID_KEY = 'pm4py:param:case_id_key'#
CASE_PREFIX = 'case:'#
CASE_ATTRIBUTES = 'case_attributes'#
CONSIDER_ALL_ATTRIBUTES = 'consider_all_attributes'#
MANDATORY_ATTRIBUTES = 'mandatory_attributes'#
MAX_NO_CASES = 'max_no_cases'#
MIN_DIFFERENT_OCC_STR_ATTR = 'min_different_occ_str_attr'#
MAX_DIFFERENT_OCC_STR_ATTR = 'max_different_occ_str_attr'#
TIMESTAMP_KEY = 'pm4py:param:timestamp_key'#
ACTIVITY_KEY = 'pm4py:param:activity_key'#
PARAM_ARTIFICIAL_START_ACTIVITY = 'pm4py:param:art_start_act'#
PARAM_ARTIFICIAL_END_ACTIVITY = 'pm4py:param:art_end_act'#
INDEX_KEY = 'index_key'#
CASE_INDEX_KEY = 'case_index_key'#
USE_EXTREMES_TIMESTAMP = 'use_extremes_timestamp'#
ADD_CASE_IDENTIFIER_COLUMN = 'add_case_identifier_column'#
DETERMINISTIC = 'deterministic'#
COUNT_OCCURRENCES = 'count_occurrences'#
ENABLE_NUMERIC_ATTRIBUTE_STATISTICS = 'enable_numeric_attribute_statistics'#
NUMERIC_ATTRIBUTE_AGGREGATIONS = 'numeric_attribute_aggregations'#
pm4py.objects.log.util.dataframe_utils.insert_partitioning(df, num_partitions, parameters=None)[source]#

Insert the partitioning in the specified dataframe

Parameters:
  • df – Dataframe

  • num_partitions – Number of partitions

  • parameters – Parameters of the algorithm

Returns:

Partitioned dataframe

Return type:

df

pm4py.objects.log.util.dataframe_utils.legacy_parquet_support(df, parameters=None)[source]#

For legacy support, Parquet files columns could not contain a “:” that has been arbitrarily replaced by a replacer string. This string substitutes the replacer to the :

Parameters:
  • dataframe – Dataframe

  • parameters – Parameters of the algorithm

pm4py.objects.log.util.dataframe_utils.table_to_stream(table, parameters=None)[source]#

Converts a Pyarrow table to an event stream

Parameters:
  • table – Pyarrow table

  • parameters – Possible parameters of the algorithm

pm4py.objects.log.util.dataframe_utils.table_to_log(table, parameters=None)[source]#

Converts a Pyarrow table to an event log

Parameters:
  • table – Pyarrow table

  • parameters – Possible parameters of the algorithm

pm4py.objects.log.util.dataframe_utils.convert_timestamp_columns_in_df(df, timest_format=None, timest_columns=None)[source]#

Convert all dataframe columns in a dataframe

Parameters:
  • df – Dataframe

  • timest_format – (If provided) Format of the timestamp columns in the CSV file

  • timest_columns – Columns of the CSV that shall be converted into timestamp

Returns:

Dataframe with timestamp columns converted

Return type:

df

pm4py.objects.log.util.dataframe_utils.sample_dataframe(df, parameters=None)[source]#

Sample a dataframe on a given number of cases

Parameters:
  • df – Dataframe

  • parameters – Parameters of the algorithm, including: - Parameters.CASE_ID_KEY - Parameters.CASE_ID_TO_RETAIN

Returns:

Sampled dataframe

Return type:

sampled_df

pm4py.objects.log.util.dataframe_utils.insert_artificial_start_end(df0: DataFrame, parameters: Dict[Any, Any] | None = None) → DataFrame[source]#

Inserts the artificial start/end activities in a Pandas dataframe

Parameters:
  • df0 – Dataframe

  • parameters – Parameters of the algorithm, including: - Parameters.CASE_ID_KEY: the case identifier - Parameters.TIMESTAMP_KEY: the timestamp - Parameters.ACTIVITY_KEY: the activity

Returns:

Dataframe with artificial start/end activities

Return type:

enriched_df

pm4py.objects.log.util.dataframe_utils.dataframe_to_activity_case_table(df: DataFrame, parameters: Dict[Any, Any] | None = None)[source]#

Transforms a Pandas dataframe into: - an “activity” table, containing the events and their attributes - a “case” table, containing the cases and their attributes

Parameters:
  • df – Dataframe

  • parameters – Parameters of the algorithm that should be used, including:

    • Parameters.CASE_ID_KEY => the column to be used as case ID (shall be included both in the activity table and the case table)

    • Parameters.CASE_PREFIX => if a list of attributes at the case level is not provided, then all the ones of the dataframe starting with one of these are considered.

    • Parameters.CASE_ATTRIBUTES => the attributes of the dataframe to be used as case columns

Returns:

  • activity_table – Activity table

  • case_table – Case table