pandas
pandas copied to clipboard
TST: Add regression test for DataFrame.where inplace consistency
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=Truewould incorrectly store floatnanwhileinplace=Falsestoredpd.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()topandas/tests/frame/indexing/test_where.py - Test verifies both
inplace=Trueandinplace=Falseproduce identical results withpd.NAfor 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
@mroeschke Updated! Removed verbose comments and simplified DataFrame construction as requested.