Skip to content

#53718 Added copy_on_write effects on pd.Dataframe.copy() method #54425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 10, 2023

Conversation

taytzehao
Copy link
Contributor


** Copy-on-Write is set to true: **

>>> pd.set_option("mode.copy_on_write", True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will set the option to True for all following tests as well, this has to be wrapped in with(pd.options_context...)

@@ -6584,6 +6584,13 @@ def copy(self, deep: bool_t | None = True) -> Self:
:ref:`gotchas <gotchas.thread-safety>` when copying in a threading
environment.

When ``copy_on_write`` in pandas global config is set to ``True``, the
``copy_on_write`` global config take effect even when ``deep=False``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``copy_on_write`` global config take effect even when ``deep=False``.
``copy_on_write`` global config takes effect even when ``deep=False``.

When ``copy_on_write`` in pandas global config is set to ``True``, the
``copy_on_write`` global config take effect even when ``deep=False``.
This means that any changes to the copied data would make a new copy
of the data upon write (and vice versa). o changes would not be reflected
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should . o changes be?

@mroeschke mroeschke added the Docs label Aug 9, 2023
@mroeschke mroeschke added this to the 2.1 milestone Aug 10, 2023
@mroeschke mroeschke merged commit c334f42 into pandas-dev:main Aug 10, 2023
@mroeschke
Copy link
Member

Thanks @taytzehao

mroeschke pushed a commit to mroeschke/pandas that referenced this pull request Aug 18, 2023
…ethod (pandas-dev#54425)

* reformat

* iloc

* option_context

* tab spacing

* reformat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: Update the DataFrame.copy docstring to note different behaviour with Copy-on-Write
3 participants