8000 API / CoW: detect and raise error for chained assignment under Copy-on-Write by jorisvandenbossche · Pull Request #49467 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add whatsnew
  • Loading branch information
jorisvandenbossche committed Jan 16, 2023
commit 4521d87c37b5fa7c51c5b65570d50da1e747e95e
8 changes: 8 additions & 0 deletions doc/source/whatsnew/v2.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ Copy-on-Write improvements
a modification to the data happens) when constructing a Series from an existing
Series with the default of ``copy=False`` (:issue:`50471`)

- Trying to set values using chained assignment (for example, ``df["a"][1:3] = 0``)
will now always raise an exception when Copy-on-Write is enabled. In this mode,
chained assignment can never work because we are always setting into a temporary
object that is the result of an indexing operation (getitem), which under
Copy-on-Write always behaves as a copy. Thus, assigning through a chain
can never update the original Series or DataFrame. Therefore, an informative
error is raised to the user instead of silently doing nothing (:issue:`49467`)

Copy-on-Write can be enabled through

.. code-block:: python
Expand Down
0