Skip to content

Fix BoxPlot KeyError when columns is not provided - #562

Merged
cachafla merged 2 commits into
mainfrom
andres/fix-boxplot-default-columns
Sep 3, 2026
Merged

cachafla merged 2 commits into
mainfrom
andres/fix-boxplot-default-columns

Conversation

@cachafla

@cachafla cachafla commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Pull Request Description

What and why?

validmind.plots.BoxPlot raised a KeyError whenever it was run without an explicit columns parameter:

KeyError: "None of [Index([None], dtype='object')] are in the [columns]"

_validate_inputs wrapped the default columns=None into [None] and indexed the dataframe with it before the if columns is None branch could run, so that branch was dead code. Because BoxPlot is tagged data_quality, this broke any loop over vm.tests.list_tests(tags=["data_quality"], ...), which is exactly what notebooks/use_cases/validation/validate_application_scorecard.ipynb does (reported by Hannes on the JupyterHub demo environment; the traceback pointed at BoxPlot._validate_inputs, not at the preprocess/feature-engineering cells).

The fix defaults to dataset.feature_columns_numeric, the same approach HistogramPlot, ViolinPlot and CorrelationHeatmap already use, and filters explicit columns against that list instead of indexing the frame directly (so a misspelled column is skipped rather than raising).

How to test

  • uv run python -m unittest tests.unit_tests.plots.test_BoxPlot (new; two of the four cases fail on main).
  • Run the for test in dq: loop in validate_application_scorecard.ipynb. All 11 data_quality tests, including validmind.plots.BoxPlot, now pass on the preprocessed lending club dataset.

What needs special review?

Explicit columns are now filtered to numeric feature columns, so passing the target column explicitly no longer plots it. This matches the sibling plot tests.

Dependencies, breaking changes, and deployment notes

None.

Release notes

Fixed validmind.plots.BoxPlot raising a KeyError when run without the columns parameter, which also broke running all data_quality tests in a loop.

Checklist

  • What and why
  • Screenshots or videos (Frontend)
  • How to test
  • What needs special review
  • Dependencies, breaking changes, and deployment notes
  • Labels applied
  • PR linked to Shortcut
  • Unit tests added (Backend)
  • Tested locally
  • Documentation updated (if required)
  • Environment variable additions/changes documented (if required)

🤖 Generated with Claude Code

_validate_inputs wrapped the default columns=None into [None] before
indexing the dataframe, so the None branch was unreachable and
run_test("validmind.plots.BoxPlot", inputs={"dataset": ds}) raised
KeyError: "None of [Index([None], dtype='object')] are in the [columns]".
This broke any loop over list_tests(tags=["data_quality"]), such as the
validate_application_scorecard notebook.

Default to dataset.feature_columns_numeric like HistogramPlot, ViolinPlot
and CorrelationHeatmap already do, and filter explicit columns against it
instead of indexing the frame directly.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@cachafla cachafla added the bug Something isn't working label Sep 3, 2026
@cachafla
cachafla requested a review from hannes-vm September 3, 2026 20:41
@cachafla
cachafla merged commit 634688c into main Sep 3, 2026
26 of 27 checks passed
@cachafla
cachafla deleted the andres/fix-boxplot-default-columns branch September 3, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants