pandas icon indicating copy to clipboard operation
pandas copied to clipboard

TST: Add regression test for DataFrame.where inplace consistency

Open zachyattack23 opened this issue 1 month ago • 1 comments

Description

Adds regression test for inconsistent behavior between DataFrame.where with inplace=True and inplace=False when using StringArray with NA-like values.

Background

  • Original bug: In pandas 2.2, inplace=True would incorrectly store float nan while inplace=False stored pd.NA
  • Status: Bug is fixed in current main (3.0.0.dev0) - both now correctly use pd.NA
  • This PR: Adds test to prevent regression

Changes

  • Added test_where_inplace_string_array_consistency() to pandas/tests/frame/indexing/test_where.py
  • Test verifies both inplace=True and inplace=False produce identical results with pd.NA for StringArray

Testing

pytest pandas/tests/frame/indexing/test_where.py::test_where_inplace_string_array_consistency -v

PASSED

Closes #46512

[x] Tests added and passed [x] All code checks passed (will verify in CI) [ ] Added type annotations (N/A - test only) [ ] Added whatsnew entry (N/A - test only) [x] Used AI following AGENTS.md

zachyattack23 avatar Dec 04 '25 03:12 zachyattack23

@mroeschke Updated! Removed verbose comments and simplified DataFrame construction as requested.

zachyattack23 avatar Dec 05 '25 17:12 zachyattack23