Skip to content

BUG: fix "boolean value of NA is ambiguous" in iloc setitem with nullable Series RHS - #726

Open
xirafa wants to merge 5 commits into
mainfrom
IMGillusion/fix-62473-iloc-setitem-nullable-na
Open

xirafa wants to merge 5 commits into
mainfrom
IMGillusion/fix-62473-iloc-setitem-nullable-na

Conversation

@xirafa

@xirafa xirafa commented Sep 8, 2026 •

Copy link
Copy Markdown

Mirror of pandas-dev/pandas#68312. Runs the pandas test suite through dagz.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed Series.iloc assignments involving nullable integer Series with missing values and non-default indexes.
    • Assignments now correctly follow positional semantics, preserve the nullable integer dtype, and avoid ambiguous missing-value errors.
  • Tests

    • Added coverage for positional assignments with nullable Series, missing values, and non-default indexes.
  • Documentation

    • Documented the fix in the pandas 3.1.0 release notes.

…able Series RHS (GH#62473)

The precision-loss check in _coerce_to_data_and_mask compared the
positionally-coerced float value against original[idx], which for a Series
does a label lookup and can land on a missing element even when the value
at that position is concrete. Access the original positionally (and guard
against a null original) so the comparison reflects the coerced value.
@coderabbitai

coderabbitai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: cc06929f-7991-46f0-b48c-dec9c92d71c8

📥 Commits

Reviewing files that changed from the base of the PR and between 84c6bc5 and 8502428.

📒 Files selected for processing (3)
  • doc/source/whatsnew/v3.1.0.rst
  • pandas/core/arrays/numeric.py
  • pandas/tests/series/indexing/test_setitem.py

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 8b969ad6-0a7f-4956-b24f-b36735dce0fc

📥 Commits

Reviewing files that changed from the base of the PR and between e7a4e15 and 84c6bc5.

📒 Files selected for processing (3)
  • doc/source/whatsnew/v3.1.0.rst
  • pandas/core/arrays/numeric.py
  • pandas/tests/series/indexing/test_setitem.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • doc/source/whatsnew/v3.1.0.rst
  • pandas/tests/series/indexing/test_setitem.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The numeric coercion path now reads nullable Series values positionally and skips null precision checks. A regression test covers Int64 Series.iloc assignment with a non-default index. The pandas 3.1.0 release notes document the fix.

Changes

Nullable Series iloc assignment

Layer / File(s) Summary
Positional nullable Series coercion
pandas/core/arrays/numeric.py, pandas/tests/series/indexing/test_setitem.py, doc/source/whatsnew/v3.1.0.rst
_coerce_to_data_and_mask uses positional access for Series values and skips comparisons when the original value is null. The test validates positional assignment and preserved Int64 dtype. The release notes document the fix.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 84c6b

The nullable Series assignment fix is covered by regression testing, with no unresolved merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main bug fix: resolving the "boolean value of NA is ambiguous" error in iloc setitem with a nullable Series RHS.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch IMGillusion/fix-62473-iloc-setitem-nullable-na

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Fix the three pre-commit.ci hook failures on the PR head:
- ruff format: rewrapped the new `if` in numeric.py and collapsed the
  new test's `pd.Series(...)` call in test_setitem.py
- sort-whatsnew-items: reordered the new v3.1.0.rst entry into sort order
- trim-trailing-whitespace: removed a trailing space in v3.1.0.rst

Cosmetic only; no behavior change (red/green and regression already green).
@xirafa
xirafa force-pushed the main branch 26 times, most recently from 059b278 to 7d51e14 Compare September 11, 2026 21:54
@xirafa
xirafa force-pushed the main branch 28 times, most recently from 4a0051b to 18e7944 Compare September 20, 2026 01:33
IMGillusion and others added 2 commits September 29, 2026 01:30
Drop the unreachable `libmissing.checknull` guard from the
GH#62473 precision-loss check and keep the positional read, plus
a no-NA regression test and a broader whatsnew entry.

xref: #62473
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants