Skip to content
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

px.timeline with a Daylight Savings Time scenario - missing/extra hour #4611

Open
rhelouREV opened this issue May 14, 2024 · 0 comments
Open

Comments

@rhelouREV
Copy link

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")

image

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")

image

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants