maaz.code logo
Simple view

Mergedpandas-dev/pandas#7121250.3Kstars

DOC: Fix non-raising set_flags example and wrong-length df.add list

By Mohd Maaz Khan, merged by jbrockmendel into pandas-dev/pandas on 17 Oct 2026

+2−22 lines added, 2 lines removed2 files changed3 comments

Conversation

  1. maaz7409opened this pull request on 15 Oct 2026description.mdAuthor

    This PR fixes two user guide examples whose code does not match the text around them.

    • a) doc/source/user_guide/duplicates.rst, line 142 ("Disallowing Duplicate Labels")

      Before: pd.DataFrame(..., columns=["A", "B", "C"]).set_flags( allows_duplicate_labels=False)

      After: pd.DataFrame(..., columns=["A", "A", "B"]).set_flags( allows_duplicate_labels=False)

      The text before the example says the flag "applies to both row and column labels for a DataFrame". The block is marked :okexcept:, so it is meant to show the error raised for duplicate column labels. But "A", "B", "C" are all unique, so set_flags succeeds and the rendered page shows a plain 2x3 DataFrame and no error. With ["A", "A", "B"] (the same labels as df1 earlier on the page) it raises DuplicateLabelError, matching the Series example just above. The labels have been unique since the example was added in #28394.

    • b) doc/source/user_guide/basics.rst, line 224 ("Matching / broadcasting behavior")

      Before: e.g. df.add([1, 2, 3], axis=0) After: e.g. df.add([1, 2, 3, 4], axis=0)

      The sentence, added in #64290, shows how to broadcast a list row-wise. The df defined in that section has 4 rows (a-d) and 3 columns, so a 3-element list with axis=0 raises "ValueError: Unable to coerce to Series, length must be 4: given 3". A 4-element list matches the number of rows and runs.

    AI Disclosure: Used Claude Code ( Sonnet 5.5 (high) ) for auditing docs, through which these issues were found.

  2. jbrockmendelcommented on 16 Oct 2026Member

    Thanks for the PR. Our review queue is backed up right now. To help us get to this sooner, could you run it through pandas-review? It's an agent skill that reviews a PR the way a maintainer would and ends with a verdict. We're considering making it part of the contributing guidelines (GH-70954).

    • Claude Code: from your pandas clone, run mkdir -p .claude/skills/pandas-review && curl -sL https://raw.githubusercontent.com/jbrockmendel/pandas/doc-gist/.claude/skills/pandas-review/SKILL.md -o .claude/skills/pandas-review/SKILL.md and then /pandas-review <this PR number>.
    • Other tools: ask your agent to follow that file, and give it this PR's number.

    It needs an authenticated gh, and it works best with the branch checked out in a built dev environment so it can run the tests. Use the strongest model and effort setting you have, in a fresh session rather than the one that wrote the change.

    Then either address the findings or reply here explaining why they don't apply. Once it reports LGTM or NITS ONLY, please leave a comment so we know it's ready for a look. If you disagree with a finding, a short note in your own words is enough.

  3. jbrockmendelapproved these changes on 17 Oct 2026

  4. jbrockmendelmerged this pull request on 17 Oct 2026

Copied from GitHub when this site was built; comments by bots are left out.