[Pandas-dev] Proposal for consistent, clear copy/view semantics in pandas with Copy-on-Write

Joris Van den Bossche jorisvandenbossche at gmail.com
Fri Jul 16 08:23:35 EDT 2021


On Mon, 12 Jul 2021 at 00:58, Joris Van den Bossche <
jorisvandenbossche at gmail.com> wrote:

> Short summary of the proposal:
>
>    1. The result of *any* indexing operation (subsetting a DataFrame or
>    Series in any way) or any method returning a new DataFrame, always *behaves
>    as if it were* a copy in terms of user API.
>
>  To explicitly call out the column-as-Series case (since this is a typical
case that right now *always* is a view): "any" indexing operation thus also
included accessing a DataFrame column as a Series (or slicing a Series).

So something like s = df["col"] and then mutating s will no longer update df.
Similarly for series_subset = series[1:5], mutating series_subset will no
longer update s.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/pandas-dev/attachments/20210716/369f8632/attachment.html>


More information about the Pandas-dev mailing list