Skip to content
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

DOC: Add note about CoW change to copy keyword docs #56162

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
60 changes: 60 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,18 @@
values must not be None.
copy : bool, default True
If False, avoid copy if possible.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``
indicator : bool or str, default False
If True, adds a column to the output DataFrame called "_merge" with
information on the source of each row. The column can be given a different
Expand Down Expand Up @@ -3728,6 +3740,18 @@ def transpose(self, *args, copy: bool = False) -> DataFrame:
Note that a copy is always required for mixed dtype DataFrames,
or for DataFrames with any extension types.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``

Returns
-------
DataFrame
Expand Down Expand Up @@ -5577,6 +5601,18 @@ def rename(
('index', 'columns') or number (0, 1). The default is 'index'.
copy : bool, default True
Also copy underlying data.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``
inplace : bool, default False
Whether to modify the DataFrame rather than creating a new one.
If True then value of copy is ignored.
Expand Down Expand Up @@ -12095,6 +12131,18 @@ def to_timestamp(
copy : bool, default True
If False then underlying input data is not copied.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``

Returns
-------
DataFrame
Expand Down Expand Up @@ -12161,6 +12209,18 @@ def to_period(
copy : bool, default True
If False then underlying input data is not copied.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``

Returns
-------
DataFrame
Expand Down
120 changes: 119 additions & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,18 @@ def set_flags(
----------
copy : bool, default False
Specify if a copy of the object should be made.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``
allows_duplicate_labels : bool, optional
Whether the returned object allows duplicate labels.

Expand Down Expand Up @@ -741,7 +753,17 @@ def set_axis(
copy : bool, default True
Whether to make a copy of the underlying data.

.. versionadded:: 1.5.0
.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``

Returns
-------
Expand Down Expand Up @@ -1172,6 +1194,18 @@ def rename_axis(
The axis to rename. For `Series` this parameter is unused and defaults to 0.
copy : bool, default None
Also copy underlying data.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``
inplace : bool, default False
Modifies the object directly, instead of creating a new Series
or DataFrame.
Expand Down Expand Up @@ -4597,6 +4631,18 @@ def reindex_like(

copy : bool, default True
Return a new object, even if the passed indexes are the same.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``
limit : int, default None
Maximum number of consecutive labels to fill for inexact matches.
tolerance : optional
Expand Down Expand Up @@ -5343,6 +5389,18 @@ def reindex(

copy : bool, default True
Return a new object, even if the passed indexes are the same.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``
level : int or name
Broadcast across a level, matching Index values on the
passed MultiIndex level.
Expand Down Expand Up @@ -6775,6 +6833,18 @@ def infer_objects(self, copy: bool_t | None = None) -> Self:
Whether to make a copy for non-object or non-inferable columns
or Series.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``

Returns
-------
same type as input object
Expand Down Expand Up @@ -10077,6 +10147,18 @@ def align(
copy : bool, default True
Always returns new objects. If copy=False and no reindexing is
required then original objects are returned.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``
fill_value : scalar, default np.nan
Value to use for missing values. Defaults to NaN, but can be any
"compatible" value.
Expand Down Expand Up @@ -11099,6 +11181,18 @@ def truncate(
copy : bool, default is True,
Return a copy of the truncated section.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``

Returns
-------
type of caller
Expand Down Expand Up @@ -11255,6 +11349,18 @@ def tz_convert(
copy : bool, default True
Also make a copy of the underlying data.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``

Returns
-------
{klass}
Expand Down Expand Up @@ -11344,6 +11450,18 @@ def tz_localize(
must be None.
copy : bool, default True
Also make a copy of the underlying data.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``
ambiguous : 'infer', bool-ndarray, 'NaT', default 'raise'
When clocks moved backward due to DST, ambiguous times may arise.
For example in Central European Time (UTC+01), when going from
Expand Down
50 changes: 49 additions & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -4295,7 +4295,19 @@ def nsmallest(
klass=_shared_doc_kwargs["klass"],
extra_params=dedent(
"""copy : bool, default True
Whether to copy underlying data."""
Whether to copy underlying data.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``"""
),
examples=dedent(
"""\
Expand Down Expand Up @@ -4948,6 +4960,18 @@ def rename(
Unused. Parameter needed for compatibility with DataFrame.
copy : bool, default True
Also copy underlying data.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``
inplace : bool, default False
Whether to return a new Series. If True the value of copy is ignored.
level : int or level name, default None
Expand Down Expand Up @@ -5732,6 +5756,18 @@ def to_timestamp(
copy : bool, default True
Whether or not to return a copy.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``

Returns
-------
Series with DatetimeIndex
Expand Down Expand Up @@ -5784,6 +5820,18 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series
copy : bool, default True
Whether or not to return a copy.

.. note::
The `copy` keyword will change behavior in pandas 3.0.
`Copy-on-Write
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
will be enabled by default, which means that all methods with a
`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``

Returns
-------
Series
Expand Down
Loading