pm4py.objects.log.util.pandas_numpy_variants module#

class pm4py.objects.log.util.pandas_numpy_variants.Parameters(*values)[source]#

Bases: Enum

CASE_ID_KEY = 'pm4py:param:case_id_key'#
ACTIVITY_KEY = 'pm4py:param:activity_key'#
TIMESTAMP_KEY = 'pm4py:param:timestamp_key'#
INDEX_KEY = 'index_key'#
pm4py.objects.log.util.pandas_numpy_variants.apply(dataframe: DataFrame, parameters=None) Tuple[Dict[Collection[str], int], Dict[str, Collection[str]]][source]#

Efficient method returning the variants from a Pandas dataframe (through Numpy)

Minimum viable example:

import pandas as pd import pm4py from pm4py.objects.log.util import pandas_numpy_variants

dataframe = pd.read_csv(‘tests/input_data/receipt.csv’) dataframe = pm4py.format_dataframe(dataframe) variants_dict, case_variant = pandas_numpy_variants.apply(dataframe)

Parameters:
  • dataframe – Dataframe

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

Returns:

  • variants_dict – Dictionary associating to each variant the number of occurrences in the dataframe

  • case_variant – Dictionary associating to each case identifier the corresponding variant