Open
Description
We are adding a new "warning" mode for the Copy-on-Write option (#48998):
pd.options.mode.copy_on_write = "warn"
which will raise a warning in every case that you are doing a setitem operation that will change behaviour when Copy-on-Write is enabled (i.e. when you are setting on an object that shares a view with another object, and with current pandas would also update that other object)
This is a tracking issue for the subtasks to complete this:
- Initial PR + tackling Series setitem (
mgr.setitem_inplace
): CoW: add warning mode for cases that will change behaviour #55428 - Single block setitem (
mgr.setitem
): CoW warning mode: add warning for single block setitem #55838 - Setting values into single column (
mgr.column_setitem
): CoW warning mode: setting values into single column of DataFrame #56020 -
mgr.iset
? (mostly used frommgr.column_setitem
which already raises the warning?) -
mgr._iset_single
? (this seems only covered bytest_internals.py::TestBlockManager::test_get_numeric_data/test_get_bool_data
, and so this is probably not possible to get to through public APIs) - Chained setitem: CoW warning mode: warn in case of chained assignment #55522
- Chained inplace methods (fillna etc)
- CoW: Warn for cases that go through putmask #56168
- False positives with inplace operators (eg
ser[0:2] += 1
) -> CoW: Remove false positive warnings for inplace operators #56242 - Update the Stata reader code to not trigger warnings (check general ignore in test_stata.py): CoW: Avoid warnings in stata code #56392
In addition, there are also a bunch of remaining # TODO(CoW-warn)
to resolve.