Repository navigation
Conversation
When x or y is a list of column names and one of them is not a column of data_frame (e.g. a typo), Plotly Express does not switch to wide mode and treats the list as data, which then fails with a misleading "All arguments should have the same length" error. In that case, raise an error naming the missing column(s) instead. Lists of strings whose length matches the other arguments are still treated as data. Closes plotly#4040
anyingiit
force-pushed
the
fix-px-wide-typo-error-4040
branch
from
October 22, 2026 20:32
4787060 to
6f69432
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue
Closes #4040
Description of change
When
x/yis a list of column names with a typo, PX doesn't enter wide mode, treats the list as data, and fails with a misleading "All arguments should have the same length" error. This PR adds a check inprocess_args_into_dataframe: if a list of strings passed tox/ycontains names that aren't columns ofdata_frameand its length doesn't match the previously-processed arguments (i.e. the "same length" error would be raised anyway), it raises an error naming the missing column(s) and listing the available ones instead. Lists of strings used as data keep working as before, even if some of them happen to match column names. A typo in anxlist that is processed before any other argument still gets the old length error, since at that point the list could still be valid data.Motivation / disclosure: I had some spare AI-assistant quota (Claude Code) and am using it to try to help projects with open issues. The change was prepared with Claude Code and verified as listed below. If it doesn't fit, or you'd simply rather not take it, please feel free to close it, no hard feelings at all 🙂
Demo
Testing strategy
Added
test_wrong_column_name_in_list(all dataframe backends; typo iny, all names wrong, and typo inywithoutxfor pandas), which fails onmain, andtest_list_of_strings_as_values_with_data_frameto check that lists of strings used as data (including ones containing column names) still work.python -m pytest tests/test_optional/test_px --ignore=.../test_imshow.py --ignore=.../test_trendline.py: 1069 passed, 3 failed (test_render_mode, which needsstatsmodels, not installed locally)ruff format --check .andruff checkon the changed files: cleanGuidelines