Skip to content

Commit

Permalink
Merge branch '166-removing-unneeded-workaround-in-managing-datetimes-…
Browse files Browse the repository at this point in the history
…inside-pandas' into 'integration'

[PRIORITY 1] Removing unneeded workaround in managing datetimes inside Pandas

Closes #166

See merge request process-mining/pm4py/pm4py-core!1141
  • Loading branch information
fit-alessandro-berti committed Oct 27, 2023
2 parents 753202c + f8b88da commit a209f0d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pm4py/objects/conversion/log/variants/to_data_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ def apply(log, parameters=None):
# Pandas 1.5.x has problems in managing datetime.datetime types
# ensure the dates are provided as np.datetime64 which is supported correctly
# until a proper fix on the Pandas side is provided
wka_dt_columns = set()
"""wka_dt_columns = set()
for ev in transf_log:
for attr in ev:
if isinstance(ev[attr], datetime):
ev[attr] = np.datetime64(ev[attr])
wka_dt_columns.add(attr)
wka_dt_columns.add(attr)"""

df = pd.DataFrame.from_dict(transf_log)

# additional requirement for the workaround: transform back np.datetime64 to datetime after the dataframe
# is created :)))
for attr in wka_dt_columns:
"""for attr in wka_dt_columns:
df[attr] = df[attr].apply(lambda x: x.to_datetime64())
df[attr] = pd.to_datetime(df[attr], utc=True)
df[attr] = pd.to_datetime(df[attr], utc=True)"""

df.attrs = copy(log.properties)
if pm4_constants.PARAMETER_CONSTANT_CASEID_KEY in df.attrs:
Expand Down

0 comments on commit a209f0d

Please sign in to comment.