plotly / plotly/plotly.py

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

Open
#4,040 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the issue's pandas and NumPy reproduction with px.line, then trace the validation path used for the x and y arguments. Done means an invalid y column name produces an accurate column-related error while valid multiple-y input continues to work; the payload does not name a specific file or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.