Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
3 changes: 3 additions & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ process in more detail.

`PDEP-7: Consistent copy/view semantics in pandas with Copy-on-Write <https://pandas.pydata.org/pdeps/0007-copy-on-write.html>`__

Setting the option ``mode.copy_on_write`` no longer has any impact. The option is deprecated
and will be removed in pandas 4.0.

.. _whatsnew_300.enhancements.col:

``pd.col`` syntax can now be used in :meth:`DataFrame.assign` and :meth:`DataFrame.loc`
Expand Down
15 changes: 11 additions & 4 deletions pandas/core/config_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,11 @@ def is_terminal() -> bool:
cf.register_option("sim_interactive", False, tc_sim_interactive_doc)


# TODO better name?
copy_on_write_doc = """
: bool
Use new copy-view behaviour using Copy-on-Write. Defaults to False,
unless overridden by the 'PANDAS_COPY_ON_WRITE' environment variable
(if set to "1" for True, needs to be set before pandas is imported).
Use new copy-view behaviour using Copy-on-Write. No longer used,
pandas now always uses Copy-on-Write behavior. This option will
be removed in pandas 4.0.
"""


Expand Down Expand Up @@ -902,3 +901,11 @@ def register_converter_cb(key: str) -> None:

# GH#59502
cf.deprecate_option("future.no_silent_downcasting", Pandas4Warning)
cf.deprecate_option(
"mode.copy_on_write",
Pandas4Warning,
msg=(
"Copy-on-Write can no longer be disabled, setting to False has no impact. "
"This option will be removed in pandas 4.0."
),
)
7 changes: 7 additions & 0 deletions pandas/tests/copy_view/test_copy_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,10 @@ def test_copy_deprecation_merge_concat():
Pandas4Warning, match="copy", check_stacklevel=False
):
concat([df, df], copy=False)


@pytest.mark.parametrize("value", [False, True, "warn"])
def test_copy_on_write_deprecation_option(value):
msg = "Copy-on-Write can no longer be disabled"
with tm.assert_produces_warning(Pandas4Warning, match=msg):
pd.set_option("mode.copy_on_write", value)
Loading