Repository navigation
fix: stop calling the deprecated DataFrame.iterrows in Layout.get_details - #1159
Open
glaziermag wants to merge 1 commit into
Open
glaziermag wants to merge 1 commit into
glaziermag wants to merge 1 commit into
Conversation
pandas 3.2 deprecates DataFrame.iterrows (pandas-dev/pandas#64719). Layout.get_details used it, so drawing any plot with pandas main emits Pandas4Warning, and the latest-pandas weekly jobs fail on the tests that check for warnings.
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.
The weekly tests against pandas
mainfail again. pandas deprecatedDataFrame.iterrowsin pandas-dev/pandas#64719 (merged 2026-11-08, in the v3.2.0 whatsnew), andLayout.get_detailsloops over the panel layout with it (plotnine/facets/layout.py:311). That runs on every draw, so every plot emits aPandas4Warning, and the latest-pandas jobs of the 2026-11-21 weekly run fail on the tests that check for warnings (https://github.com/has2k1/plotnine/actions/runs/44916327374):The loop now pairs the index with
to_dict("records"), sopanel_indexand the row values it reads stay the same. pyright then reports the# type: ignoreonpanel_indexas unnecessary, so that comment goes too.To reproduce, with a pandas nightly (
pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas):Checks (macOS):
pytest testsgives 5 failed, 992 passed before and 997 passed after (warnings 1990 → 40).--resolution=lowest-direct): the same test results before and after.Layout.get_details()returns the same values with the same types before and after forfacet_null,facet_wrap(fixed and free scales) andfacet_grid(with and without margins), on all three pandas versions.main, which this does not touch. In the build run https://github.com/glaziermag/plotnine/actions/runs/45675945795 lint, typecheck and the 3.14 tests pass; the unittests jobs are red only because the Codecov upload needs a token the fork does not have.#1145 also rewrites this loop as part of the narwhals port. This change does not depend on it.
Prepared with Claude Code (Claude Opus 5.5): it found the failing weekly run, wrote the change and ran the checks above.
🤖 Generated with Claude Code