File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -6590,6 +6590,13 @@ def copy(self, deep: bool_t | None = True) -> Self:
65906590 :ref:`gotchas <gotchas.thread-safety>` when copying in a threading
65916591 environment.
65926592
6593+ When ``copy_on_write`` in pandas config is set to ``True``, the
6594+ ``copy_on_write`` config takes effect even when ``deep=False``.
6595+ This means that any changes to the copied data would make a new copy
6596+ of the data upon write (and vice versa). Changes made to either the
6597+ original or copied variable would not be reflected in the counterpart.
6598+ See :ref:`Copy_on_Write <copy_on_write>` for more information.
6599+
65936600 Examples
65946601 --------
65956602 >>> s = pd.Series([1, 2], index=["a", "b"])
@@ -6657,6 +6664,21 @@ def copy(self, deep: bool_t | None = True) -> Self:
66576664 0 [10, 2]
66586665 1 [3, 4]
66596666 dtype: object
6667+
6668+ ** Copy-on-Write is set to true: **
6669+
6670+ >>> with pd.option_context("mode.copy_on_write", True):
6671+ ... s = pd.Series([1, 2], index=["a", "b"])
6672+ ... copy = s.copy(deep=False)
6673+ ... s.iloc[0] = 100
6674+ ... s
6675+ a 100
6676+ b 2
6677+ dtype: int64
6678+ >>> copy
6679+ a 1
6680+ b 2
6681+ dtype: int64
66606682 """
66616683 data = self ._mgr .copy (deep = deep )
66626684 self ._clear_item_cache ()
You can’t perform that action at this time.
0 commit comments