Bar chart with timeseries index not displaying depending on proximity of the times
未關閉
還沒有人認領這個 Issue。
bug
P3
- 主要語言
- Python
- 星號
- 18.8k
- 分支
- 2.8k
- 平均合併
- 16 小時 26 分鐘
- 30 天內合併 PR
- 21
描述
Found an issue causing a bar chart to display nothing when displaying timeseries data. It seems to be caused by having stacked data at two points which are very close in time (e.g. 12:00:00 and 12:00:01) and then one point much further away (e.g. 17:00:00).
import pandas as pd
import plotly.express as px
times = ['2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:01']
#times = ['2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:00'] <-- works
vals = [10, 50, 20, 350, 250]
# Uncomment to cause bar chart to display no data
# times.append('2020-12-18 13:00:00')
# vals.append(1)
df = pd.DataFrame(list(zip(times, vals)),
columns =['DT', 'Val'])
df['DT'] = pd.to_datetime(df['DT'])
df = df.set_index('DT')
fig = px.bar(df, x=df.index, y=df['Val'])
fig.show()
- The code unchanged displays the figure fine

- If you uncomment the two append lines, adding in a data point which is further away, then the figure is empty

- If you uncomment the two append lines and changes the initial times list so that they are all :00, the figure displays fine

Therefore it seems to be caused by having points at 02:15:00 / 02:15:01 and then a point much later at 13:00:00
Thanks
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先執行該 issue 的 pandas 和 Plotly Express 重現,先使用接近的時間戳,然後加入 13:00:00 這個資料點。在兩種情況下比較產生的 figure 資料或渲染結果;當長條圖能在失敗的情況下顯示所提供的時間序列資料,同時不破壞正常運作的範例時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- pandas, plotly, python
- 領域
- data-visualization
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100