plotly / plotly/plotly.py

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

オープン
#4,611 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P3 sev-3
主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
21

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、issue にある pandas と px.timeline の両方の例を再現し、3月と11月の DST の切り替えを対象にします。px.timeline のエントリポイントから、タイムゾーン対応のタイムスタンプの処理を追跡し、両方のケースに対するリグレッションテストを追加します。各バーが意図したローカルの暦上の間隔を、1時間の欠落や余分な時間なしにカバーすれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
pandas, python
領域
data-visualization
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。