From 1de490702a888c1a58819c783866a9ad5d4fb10e Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Sat, 18 Nov 2023 00:32:41 +0100 Subject: [PATCH 1/5] DOC: Add note for copy keywords for Copy-on-Write --- pandas/core/generic.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index e2e81155e1a1d..5cf4210de31ba 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -6428,6 +6428,15 @@ def astype( Return a copy when ``copy=True`` (be very careful setting ``copy=False`` as changes to values then may propagate to other pandas objects). + + .. note:: + The copy-keyword will change behavior in pandas 3.0. + `Copy-on-Write + `__ + will be enabled by default, which means that all methods with a + copy-keyword will use a lazy copy mechanism and ignore the copy + keyword. The copy-keyword will be removed in a future version of + pandas. errors : {'raise', 'ignore'}, default 'raise' Control raising of exceptions on invalid data for provided dtype. From e74072cbc3d98b16afa9975f0c4daf98e1b07ce7 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Mon, 20 Nov 2023 15:25:45 +0100 Subject: [PATCH 2/5] Update pandas/core/generic.py Co-authored-by: Joris Van den Bossche --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 5cf4210de31ba..6dfe59f2c5082 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -6434,7 +6434,7 @@ def astype( `Copy-on-Write `__ will be enabled by default, which means that all methods with a - copy-keyword will use a lazy copy mechanism and ignore the copy + `copy` keyword will use a lazy copy mechanism and ignore the `copy` keyword. The copy-keyword will be removed in a future version of pandas. errors : {'raise', 'ignore'}, default 'raise' From afd466e0ee1fefa4f25bcd1ce8b21dd2f7d189af Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Mon, 20 Nov 2023 15:25:51 +0100 Subject: [PATCH 3/5] Update pandas/core/generic.py Co-authored-by: Joris Van den Bossche --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 6dfe59f2c5082..7d18db4419cce 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -6435,7 +6435,7 @@ def astype( `__ will be enabled by default, which means that all methods with a `copy` keyword will use a lazy copy mechanism and ignore the `copy` - keyword. The copy-keyword will be removed in a future version of + keyword. The `copy` keyword will be removed in a future version of pandas. errors : {'raise', 'ignore'}, default 'raise' Control raising of exceptions on invalid data for provided dtype. From 59c883fdbd3f30d543585641e152854715b7b51f Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Mon, 20 Nov 2023 15:25:57 +0100 Subject: [PATCH 4/5] Update pandas/core/generic.py Co-authored-by: Joris Van den Bossche --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 7d18db4419cce..84b9e695a14ef 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -6430,7 +6430,7 @@ def astype( pandas objects). .. note:: - The copy-keyword will change behavior in pandas 3.0. + The `copy` keyword will change behavior in pandas 3.0. `Copy-on-Write `__ will be enabled by default, which means that all methods with a From cd564cb914d14a2221f4523892672c3d90e9a80d Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Mon, 20 Nov 2023 15:28:24 +0100 Subject: [PATCH 5/5] Update docs --- pandas/core/generic.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 84b9e695a14ef..47ecd8c0a8fc3 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -6434,9 +6434,12 @@ def astype( `Copy-on-Write `__ will be enabled by default, which means that all methods with a - `copy` keyword will use a lazy copy mechanism and ignore the `copy` - keyword. The `copy` keyword will be removed in a future version of - pandas. + `copy` keyword will use a lazy copy mechanism to defer the copy and + ignore the `copy` keyword. The `copy` keyword will be removed in a + future version of pandas. + + You can already get the future behavior and improvements through + enabling copy on write ``pd.options.mode.copy_on_write = True`` errors : {'raise', 'ignore'}, default 'raise' Control raising of exceptions on invalid data for provided dtype.