`px.timeline` with a Daylight Savings Time scenario - missing/extra hour
未关闭
还没有人认领这个 Issue。
bug
P3
sev-3
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 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")
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).
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先重现 issue 中的 pandas 和 px.timeline 示例,覆盖 3 月和 11 月的 DST 转换。跟踪 px.timeline 入口点对时区感知时间戳的处理,并为这两种情况添加回归测试。完成的标准是每个条形都覆盖预期的本地日历时间区间,既不缺少一小时,也不多出一小时。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- pandas, python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100