Open
Description
Problem:
When using px.timeline
on a range where a Daylight Savings Time switch occurs & time zones are in the timestamps, I observe an unexpectedly shorter/longer duration of the bar.
Example A - March - missing an hour
import pandas as pd
import plotly.express as px
df = pd.DataFrame(dict(
x_start=[
pd.Timestamp("2024-03-09", tz="US/Pacific"),
pd.Timestamp("2024-03-10", tz="US/Pacific"),
pd.Timestamp("2024-03-11", tz="US/Pacific"),
],
x_end=[
pd.Timestamp("2024-03-10", tz="US/Pacific"),
pd.Timestamp("2024-03-11", tz="US/Pacific"),
pd.Timestamp("2024-03-12", tz="US/Pacific"),
],
y=[1, 1, 1],
))
px.timeline(df, x_start="x_start", x_end="x_end", y="y")
As you can see, for the DST day (March 10, 2024), the end date is unexpectedly 1 hour early, unlike the other days.
Example B - November - extra hour
import pandas as pd
import plotly.express as px
df = pd.DataFrame(dict(
x_start=[
pd.Timestamp("2023-11-05", tz="US/Pacific"),
],
x_end=[
pd.Timestamp("2023-11-06", tz="US/Pacific"),
],
y=[1],
))
px.timeline(df, x_start="x_start", x_end="x_end", y="y")
In this example, 1 hour is unexpectedly added to the end.
Testing environment:
- Google Colab (also experienced on VS Code & html)
- Latest version of plotly (5.22.0).