-
-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Error handling timezones #305
Comments
Can be fixed by |
But fix only works when there is no switch to DST. Timezone Canada/Pacific, for example, changes timezone upon switch to and from DST, so if the above code is run like
you get the error: Is there a reason not to use |
You can also try using the pytz library to handle timezone conversions and DST transitions. Here's an example: import pytz ...x = pd.date_range("2024-04-01T00:00:00", "2025-01-01T00:00:00", freq="H") ...relayout_data = { |
I tried to fix this behavior in #318 by catching the legacy
However, this introduces the possibly unwanted behavior, that different timezones with the same offset, are considered valid. (e.g. "Europe/Brussels" and "Europe/Amsterdam" are two different timezone objects / strings, but with the same offset -> so they are considered as equal.) This is also expressed in the following tests: plotly-resampler/tests/test_figure_resampler.py Lines 1051 to 1098 in 1f88adb
I would like to hear your opinion on this matter before continuing on this PR. |
@Jmbols @DHRUVCHARNE, any thoughts/remarks on my above comment? |
This is the behaviour I would expect. "Europe/Brussels" and "Europe/Amsterdam" are equivalent for all intents and purposes. The main issue I can see with that is if they have different dates when switching to and from DST, but presumably this would be caught by the offset check? |
Description
There is an error trying to construct an update patch when the x-axis are dates with a specified timezone.
The error is when trying to compare timezones. Pandas pd.to_datetime() by default will convert a timezone to a fixed off-set, whereas the timezone in the x-axis has a different format. The off-set is the same because the data is created based on the same timezone.
/.pyenv/versions/3.11.1/envs/clearview-dash-311/lib/python3.11/site-packages/plotly_resampler/aggregation/plotly_aggregator_parser.py", line 41, in to_same_tz
assert ts.tz.str() == reference_tz.str()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Reproducing the bug 🔍
This code snippet reproduces the bug
Environment information
The text was updated successfully, but these errors were encountered: