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?

xref #48998