Skip to content

BUG: replace with None cast unmatched same-dtype columns to object (GH#30512) - #1444

Open
xirafa wants to merge 1 commit into
mainfrom
jbrockmendel/bug-30512
Open

xirafa wants to merge 1 commit into
mainfrom
jbrockmendel/bug-30512

Conversation

@xirafa

@xirafa xirafa commented Oct 10, 2026 •

Copy link
Copy Markdown

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

Summary by CodeRabbit

  • Bug Fixes
    • Fixed DataFrame.replace so replacing matching values with None no longer changes the dtype of other, unmatched columns.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

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

Next included review available in 32 minutes.

Check out review usage here.

View limit details

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

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 26ac58a1-3ac6-4b1f-a06e-4b1db153edfe

📥 Commits

Reviewing files that changed from the base of the PR and between e64dcba and 8c4ec27.


📒 Files selected for processing (1)
  • doc/source/whatsnew/v3.2.0.rst

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 025474de-ac76-40be-8eff-227eee13f366


📥 Commits

Reviewing files that changed from the base of the PR and between ea1375c and e64dcba.



📒 Files selected for processing (3)
  • doc/source/whatsnew/v3.2.0.rst
  • pandas/core/internals/blocks.py
  • pandas/tests/frame/methods/test_replace.py


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




📝 Walkthrough
📝 Walkthrough

Walkthrough

Block._replace_coerce now processes qualifying columns separately when replacing None. A regression test checks that unmatched columns retain their original dtypes, and the release notes describe the fix.

Changes

DataFrame.replace dtype handling

Layer / File(s) Summary
Per-column replacement and regression coverage
pandas/core/internals/blocks.py, pandas/tests/frame/methods/test_replace.py, doc/source/whatsnew/v3.2.0.rst
When a replacement mask does not match every column in a qualifying block, replacement now splits the block and retries per column. The test covers inplace and non-inplace calls and checks the resulting values and dtypes. The release notes describe the case.

Priority: ⬇️ Low

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

Change: Bug fix

Suggested reviewers: jbrockmendel



Merge Risk: ⚪ Minimal · up to e64dc

This change stops DataFrame.replace from converting unmatched columns to object dtype when replacing with None. A regression test and release note are included. No merge-blocking risk was identified.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 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 identifies the main bug fix: replacing with None no longer casts unmatched same-dtype columns to object. It is concise and includes the related issue number.
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 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)




✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR



🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@xirafa
xirafa force-pushed the main branch 11 times, most recently from c85b9f5 to a5a62b9 Compare October 11, 2026 16:44
…H#30512)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xirafa
xirafa force-pushed the main branch 2 times, most recently from 1c2aae1 to 7edc0f5 Compare October 11, 2026 19:32
@xirafa
xirafa force-pushed the jbrockmendel/bug-30512 branch from e64dcba to 8c4ec27 Compare October 11, 2026 20:51
@xirafa
xirafa force-pushed the main branch 14 times, most recently from 9e87d20 to aaf445d Compare October 13, 2026 03:34
@xirafa
xirafa force-pushed the main branch 30 times, most recently from ef1f5bc to 3d4a7fc Compare October 16, 2026 21:07
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