I have a time series with ambiguous dates due to the daylight savings time change that I would like to convert to unique datetimes with time zone information:
- 2021-10-31 02:00 > 2021-10-31 02:00:00+02:00
- 2021-10-31 02:15 > 2021-10-31 02:15:00+02:00
- 2021-10-31 02:30 > 2021-10-31 02:30:00+02:00
- 2021-10-31 02:45 > 2021-10-31 02:45:00+02:00
- 2021-10-31 02:00 > 2021-10-31 02:00:00+01:00
- 2021-10-31 02:15 > 2021-10-31 02:15:00+01:00
- 2021-10-31 02:30 > 2021-10-31 02:30:00+01:00
- 2021-10-31 02:45 > 2021-10-31 02:45:00+01:00
I tried to do this in FME with the "TimeZoneSet"-function as described in https://community.safe.com/s/article/converting-time-and-date-fields-to-local-timezones. This works for all datetimes except the ambigous ones above (I get null values).
In Python this can easily be done by using pandas and the option "ambigous='infer'":
import pandas as pd
df = pd.read_csv(file, sep=';', parse_dates=['dt'])
df['dt'] = df['dt'].dt.tz_localize('CET', ambiguous='infer')
For this reason I wanted to use this code in a PythonCaller. But unfortunately this does not work. I assume this is because FME can not handle pandas DataFrame objects, see https://community.safe.com/s/question/0D54Q000080hYEoSAM/displaying-data-frame-in-python-caller. I got errors like:
- AttributeError: Can only use .dt accessor with datetimelike values
Any tips on how I could solve this problem?