plotly / plotly/plotly.py

Misleading error message when an invalid y column name is provided to px.line

未關閉
#4,040 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

bug P3
主要語言
Python
星號
18.8k
分支
2.8k
平均合併
16 小時 26 分鐘
30 天內合併 PR
21

描述

When attempting to plot multiple y values using px.line (or similar), erroneous column names lead to a misleading error message that states that the length of the arguments is incorrect, when in fact the problem is that there the column name is wrong.

Simple to reproduce:

import plotly.express as px
import pandas as pd
import numpy as np
x = np.linspace(0, 10, 100)
data1 = x**2
data2 = x**3
df = pd.DataFrame({"x": x, "data1": data1, "data2": data2})
px.line(df, x = "x", y = ["data1", "data2"]) # works fine
px.line(df, x = "x", y = ["data1", "Data2"]) 

# this last line gives a misleading error message: 
# ValueError: All arguments should have the same length. The length of argument `y` is 2, 
# whereas the length of  previously-processed arguments ['x'] is 100

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

首先使用 px.line 執行該 issue 的 pandas 和 NumPy 重現,然後追蹤用於 x 和 y 引數的驗證路徑。當無效的 y 欄位名稱產生準確的欄位相關錯誤,且有效的多 y 輸入持續正常運作時,即表示完成;payload 未指定特定的檔案或測試。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
data-visualization
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。