You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Often timezone offset is specified as UTC or GMT plus-minus some number, e.g. GMT+02:00 for Central European time. UTC time can be calculated by subtracting the offset from the local time. The same way the local time is calculated by adding the offset to UTC time.
For example that's how this is done in JavaScript:
> console.log(new Date('2019-10-15T15:00:12.220Z'));
Tue Oct 15 2019 17:00:12 GMT+0200 (Central European Summer Time)
But dateutil interprets timezone offset completely opposite:
See #70. The current way is a standard, and it's triggered by the offset being in the form that more closely matches that standard. In the future, we will likely add an option to invert that parsing logic.
If you apply directly the offset with utc=True, you will see that lines 14 & 16 have become the same timestamps. GC['date'] = pd.to_datetime(my_timestamps, utc=True)
I noticed the trouble as I want these timestamps to be indexes for my dataframe. I activate 'verify_integrity' which detects these duplicates.
GC.set_index('date', inplace = True, verify_integrity = True)
ValueError: Index has duplicate keys: Index([2019-10-27 02:00:00-01:00, 2019-10-27 03:00:00-01:00], dtype='object', name='date')
I am sorry, I gave only pandas related commands, but I opened this as a bug in their bugtracker. pandas-dev/pandas#30518
They are using dateutil and could check they get the same trouble.
They closed the issue, asking me to re-open it here.
I could see I am not the 1st to notice this "reversed" offset trouble.
Please, if there is no consensus on how should be applied the offset, can you let the choice to the coder through an option in the parser?
Also, I am quite a newbie, I am sorry, what would be your recommendation to get around this trouble?
I thank you in advance for your help.
Have a good day,
Bests,
Pierre
Often timezone offset is specified as UTC or GMT plus-minus some number, e.g. GMT+02:00 for Central European time. UTC time can be calculated by subtracting the offset from the local time. The same way the local time is calculated by adding the offset to UTC time.
For example that's how this is done in JavaScript:
But dateutil interprets timezone offset completely opposite:
According to code comments this behaviour is as designed (https://github.com/dateutil/dateutil/blame/master/dateutil/parser/_parser.py#L803). But shouldn't it be changed to conform to interpretation the has become a standard?
The text was updated successfully, but these errors were encountered: