Apr-08-2024, 10:29 PM
Hi,
I am currently trying to create an object-centric event log from a csv-file, which I am using the PM4PY library to. This is the function I created to achieve that:
I came across two problems, while using this function:
1. I am not able to specify object attributes in the log conversion to ocel. I asked the support line why this is not possible , but have not received an answer yet.
2. Some of the object:types contain 'nan' values. In the outputted OCEL, these 'nan' values are treated as objects of that object type and distort the outcome.
Has anybody here worked with PM4PY in the context of OCEL creation before and could provide some intuition? Help would be much appreciated.
I am not even sure if my approach to OCEL creation is the right way to do it, since it is more commonly practiced to transform a CSV-file to JSON-OCEL or XML-OCEL format beforehand, which I tried, but were not able to accomplish due to inexperience with both data formats.
Best regards and thank you!
I am currently trying to create an object-centric event log from a csv-file, which I am using the PM4PY library to. This is the function I created to achieve that:
def read_and_convert_to_ocel(filename): # Read the CSV file into a DataFrame ev = pd.read_csv(filename) # Convert the "ocel:timestamp" column to datetime format ev['ocel:timestamp'] = pd.to_datetime(ev['ocel:timestamp'], format='%Y-%m-%d %H:%M:%S') # Convert all columns except "ocel:timestamp" to string cols_to_convert = ev.columns.drop('ocel:timestamp') ev[cols_to_convert] = ev[cols_to_convert].astype(str) # Create event log from DataFrame el = pm4py.convert.convert_to_event_log(ev, 'ocel:eid') # List of object types column_headers = [ 'ocel:type:1', 'ocel:type:2', 'ocel:type:3', ] # List of event attributes event_attributes = ['attribute1', 'attribute2', 'attribute3'] # Convert event log to OCEL ocel = pm4py.convert.convert_log_to_ocel(el, 'ocel:activity', 'ocel:timestamp', column_headers, ',', event_attributes) return ocelThe input file is a pre-processed csv-file according to ocel 1.0 specifications. An example CSV file can be found under "Eventlogs" here: https://ocel-standard.org/1.0/
I came across two problems, while using this function:
1. I am not able to specify object attributes in the log conversion to ocel. I asked the support line why this is not possible , but have not received an answer yet.
2. Some of the object:types contain 'nan' values. In the outputted OCEL, these 'nan' values are treated as objects of that object type and distort the outcome.
Has anybody here worked with PM4PY in the context of OCEL creation before and could provide some intuition? Help would be much appreciated.
I am not even sure if my approach to OCEL creation is the right way to do it, since it is more commonly practiced to transform a CSV-file to JSON-OCEL or XML-OCEL format beforehand, which I tried, but were not able to accomplish due to inexperience with both data formats.
Best regards and thank you!