BUG / CoW: also return new object in case of null slice for both rows and columsn (.(i)loc[:, :]) by jorisvandenbossche · Pull Request #49469 · pandas-dev/pandas (original) (raw)
Related to #49450 (also ensuring we always return new objects from indexing operations, but for a different case).
Currently, there is the specific corner case of df.(i)loc[:, :]
that just returns df
(this doesn't happen for df.(i)loc[:]
or df[:]
, where only a single dimension gets indexed)
Given the current inconsistency with df.loc[:, :]
vs df.loc[:]
, we could also consider changing this for 2.0 for the default behaviour as well, and not just for when CoW is enabled?
- Tests added and passed if fixing a bug or adding a new feature
- All code checks passed.
- Added type annotations to new arguments/methods/functions.
- Added an entry in the latest
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.
xref #48998