Closed rsalas90 closed 2 years ago
Dear rsalas, try to verify the type of the variable log (print(type(log))).
I can ensure that examples like the following are working well in the current release:
import pm4py
log = pm4py.read_xes("tests/input_data/receipt.xes") print(type(log))
from pm4py.algo.filtering.log.timestamp import timestamp_filter filtered_log = timestamp_filter.filter_traces_contained(log, "2011-03-09 00:00:00", "2012-01-18 23:59:59")
As you can see, the type is an eventlog object
In the same way, if I want to see the frequency along with the Petrinet after applying alpha miner algorithm I receive the following error. What could be happening?
Ok it's not the typing.
I think that the problem is that the type of the timestamp variable in your events (time:timestamp) is string. This can be corrected as in the following example using the module dateutil:
import pm4py import pandas as pd dataframe = pd.read_csv("C:/receipt.csv") log = pm4py.convert_to_event_log(dataframe) from dateutil.parser import parse for trace in log: ... for event in trace: ... event["time:timestamp"] = parse(event["time:timestamp"])
Thank you! That's was the problem, now it's working properly! I had to modify previously the type of the timestamp:
pd.todatetime(df.TIMESTAMP).dt.tz_localize('UTC')
You're welcome!
When trying to filter on timeframe I receive the following error:
filtered_log = timestamp_filter.filter_traces_contained(log, "2011-01-06 15:06:00", "2022-06-30 17:56:31")
TypeError: replace() takes no keyword arguments filter traces pm4py