Skip to content

Commit 6f245e6

Browse files
authored
DOC: Add note about CoW change to copy keyword docs (#56162)
1 parent 2a0e253 commit 6f245e6

File tree

3 files changed

+228
-2
lines changed

3 files changed

+228
-2
lines changed

pandas/core/frame.py

+60
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,18 @@
370370
values must not be None.
371371
copy : bool, default True
372372
If False, avoid copy if possible.
373+
374+
.. note::
375+
The `copy` keyword will change behavior in pandas 3.0.
376+
`Copy-on-Write
377+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
378+
will be enabled by default, which means that all methods with a
379+
`copy` keyword will use a lazy copy mechanism to defer the copy and
380+
ignore the `copy` keyword. The `copy` keyword will be removed in a
381+
future version of pandas.
382+
383+
You can already get the future behavior and improvements through
384+
enabling copy on write ``pd.options.mode.copy_on_write = True``
373385
indicator : bool or str, default False
374386
If True, adds a column to the output DataFrame called "_merge" with
375387
information on the source of each row. The column can be given a different
@@ -3729,6 +3741,18 @@ def transpose(self, *args, copy: bool = False) -> DataFrame:
37293741
Note that a copy is always required for mixed dtype DataFrames,
37303742
or for DataFrames with any extension types.
37313743
3744+
.. note::
3745+
The `copy` keyword will change behavior in pandas 3.0.
3746+
`Copy-on-Write
3747+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
3748+
will be enabled by default, which means that all methods with a
3749+
`copy` keyword will use a lazy copy mechanism to defer the copy and
3750+
ignore the `copy` keyword. The `copy` keyword will be removed in a
3751+
future version of pandas.
3752+
3753+
You can already get the future behavior and improvements through
3754+
enabling copy on write ``pd.options.mode.copy_on_write = True``
3755+
37323756
Returns
37333757
-------
37343758
DataFrame
@@ -5590,6 +5614,18 @@ def rename(
55905614
('index', 'columns') or number (0, 1). The default is 'index'.
55915615
copy : bool, default True
55925616
Also copy underlying data.
5617+
5618+
.. note::
5619+
The `copy` keyword will change behavior in pandas 3.0.
5620+
`Copy-on-Write
5621+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
5622+
will be enabled by default, which means that all methods with a
5623+
`copy` keyword will use a lazy copy mechanism to defer the copy and
5624+
ignore the `copy` keyword. The `copy` keyword will be removed in a
5625+
future version of pandas.
5626+
5627+
You can already get the future behavior and improvements through
5628+
enabling copy on write ``pd.options.mode.copy_on_write = True``
55935629
inplace : bool, default False
55945630
Whether to modify the DataFrame rather than creating a new one.
55955631
If True then value of copy is ignored.
@@ -12107,6 +12143,18 @@ def to_timestamp(
1210712143
copy : bool, default True
1210812144
If False then underlying input data is not copied.
1210912145
12146+
.. note::
12147+
The `copy` keyword will change behavior in pandas 3.0.
12148+
`Copy-on-Write
12149+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
12150+
will be enabled by default, which means that all methods with a
12151+
`copy` keyword will use a lazy copy mechanism to defer the copy and
12152+
ignore the `copy` keyword. The `copy` keyword will be removed in a
12153+
future version of pandas.
12154+
12155+
You can already get the future behavior and improvements through
12156+
enabling copy on write ``pd.options.mode.copy_on_write = True``
12157+
1211012158
Returns
1211112159
-------
1211212160
DataFrame
@@ -12173,6 +12221,18 @@ def to_period(
1217312221
copy : bool, default True
1217412222
If False then underlying input data is not copied.
1217512223
12224+
.. note::
12225+
The `copy` keyword will change behavior in pandas 3.0.
12226+
`Copy-on-Write
12227+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
12228+
will be enabled by default, which means that all methods with a
12229+
`copy` keyword will use a lazy copy mechanism to defer the copy and
12230+
ignore the `copy` keyword. The `copy` keyword will be removed in a
12231+
future version of pandas.
12232+
12233+
You can already get the future behavior and improvements through
12234+
enabling copy on write ``pd.options.mode.copy_on_write = True``
12235+
1217612236
Returns
1217712237
-------
1217812238
DataFrame

pandas/core/generic.py

+119-1
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,18 @@ def set_flags(
456456
----------
457457
copy : bool, default False
458458
Specify if a copy of the object should be made.
459+
460+
.. note::
461+
The `copy` keyword will change behavior in pandas 3.0.
462+
`Copy-on-Write
463+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
464+
will be enabled by default, which means that all methods with a
465+
`copy` keyword will use a lazy copy mechanism to defer the copy and
466+
ignore the `copy` keyword. The `copy` keyword will be removed in a
467+
future version of pandas.
468+
469+
You can already get the future behavior and improvements through
470+
enabling copy on write ``pd.options.mode.copy_on_write = True``
459471
allows_duplicate_labels : bool, optional
460472
Whether the returned object allows duplicate labels.
461473
@@ -742,7 +754,17 @@ def set_axis(
742754
copy : bool, default True
743755
Whether to make a copy of the underlying data.
744756
745-
.. versionadded:: 1.5.0
757+
.. note::
758+
The `copy` keyword will change behavior in pandas 3.0.
759+
`Copy-on-Write
760+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
761+
will be enabled by default, which means that all methods with a
762+
`copy` keyword will use a lazy copy mechanism to defer the copy and
763+
ignore the `copy` keyword. The `copy` keyword will be removed in a
764+
future version of pandas.
765+
766+
You can already get the future behavior and improvements through
767+
enabling copy on write ``pd.options.mode.copy_on_write = True``
746768
747769
Returns
748770
-------
@@ -1173,6 +1195,18 @@ def rename_axis(
11731195
The axis to rename. For `Series` this parameter is unused and defaults to 0.
11741196
copy : bool, default None
11751197
Also copy underlying data.
1198+
1199+
.. note::
1200+
The `copy` keyword will change behavior in pandas 3.0.
1201+
`Copy-on-Write
1202+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
1203+
will be enabled by default, which means that all methods with a
1204+
`copy` keyword will use a lazy copy mechanism to defer the copy and
1205+
ignore the `copy` keyword. The `copy` keyword will be removed in a
1206+
future version of pandas.
1207+
1208+
You can already get the future behavior and improvements through
1209+
enabling copy on write ``pd.options.mode.copy_on_write = True``
11761210
inplace : bool, default False
11771211
Modifies the object directly, instead of creating a new Series
11781212
or DataFrame.
@@ -4598,6 +4632,18 @@ def reindex_like(
45984632
45994633
copy : bool, default True
46004634
Return a new object, even if the passed indexes are the same.
4635+
4636+
.. note::
4637+
The `copy` keyword will change behavior in pandas 3.0.
4638+
`Copy-on-Write
4639+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
4640+
will be enabled by default, which means that all methods with a
4641+
`copy` keyword will use a lazy copy mechanism to defer the copy and
4642+
ignore the `copy` keyword. The `copy` keyword will be removed in a
4643+
future version of pandas.
4644+
4645+
You can already get the future behavior and improvements through
4646+
enabling copy on write ``pd.options.mode.copy_on_write = True``
46014647
limit : int, default None
46024648
Maximum number of consecutive labels to fill for inexact matches.
46034649
tolerance : optional
@@ -5344,6 +5390,18 @@ def reindex(
53445390
53455391
copy : bool, default True
53465392
Return a new object, even if the passed indexes are the same.
5393+
5394+
.. note::
5395+
The `copy` keyword will change behavior in pandas 3.0.
5396+
`Copy-on-Write
5397+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
5398+
will be enabled by default, which means that all methods with a
5399+
`copy` keyword will use a lazy copy mechanism to defer the copy and
5400+
ignore the `copy` keyword. The `copy` keyword will be removed in a
5401+
future version of pandas.
5402+
5403+
You can already get the future behavior and improvements through
5404+
enabling copy on write ``pd.options.mode.copy_on_write = True``
53475405
level : int or name
53485406
Broadcast across a level, matching Index values on the
53495407
passed MultiIndex level.
@@ -6776,6 +6834,18 @@ def infer_objects(self, copy: bool_t | None = None) -> Self:
67766834
Whether to make a copy for non-object or non-inferable columns
67776835
or Series.
67786836
6837+
.. note::
6838+
The `copy` keyword will change behavior in pandas 3.0.
6839+
`Copy-on-Write
6840+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
6841+
will be enabled by default, which means that all methods with a
6842+
`copy` keyword will use a lazy copy mechanism to defer the copy and
6843+
ignore the `copy` keyword. The `copy` keyword will be removed in a
6844+
future version of pandas.
6845+
6846+
You can already get the future behavior and improvements through
6847+
enabling copy on write ``pd.options.mode.copy_on_write = True``
6848+
67796849
Returns
67806850
-------
67816851
same type as input object
@@ -10113,6 +10183,18 @@ def align(
1011310183
copy : bool, default True
1011410184
Always returns new objects. If copy=False and no reindexing is
1011510185
required then original objects are returned.
10186+
10187+
.. note::
10188+
The `copy` keyword will change behavior in pandas 3.0.
10189+
`Copy-on-Write
10190+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
10191+
will be enabled by default, which means that all methods with a
10192+
`copy` keyword will use a lazy copy mechanism to defer the copy and
10193+
ignore the `copy` keyword. The `copy` keyword will be removed in a
10194+
future version of pandas.
10195+
10196+
You can already get the future behavior and improvements through
10197+
enabling copy on write ``pd.options.mode.copy_on_write = True``
1011610198
fill_value : scalar, default np.nan
1011710199
Value to use for missing values. Defaults to NaN, but can be any
1011810200
"compatible" value.
@@ -11161,6 +11243,18 @@ def truncate(
1116111243
copy : bool, default is True,
1116211244
Return a copy of the truncated section.
1116311245
11246+
.. note::
11247+
The `copy` keyword will change behavior in pandas 3.0.
11248+
`Copy-on-Write
11249+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
11250+
will be enabled by default, which means that all methods with a
11251+
`copy` keyword will use a lazy copy mechanism to defer the copy and
11252+
ignore the `copy` keyword. The `copy` keyword will be removed in a
11253+
future version of pandas.
11254+
11255+
You can already get the future behavior and improvements through
11256+
enabling copy on write ``pd.options.mode.copy_on_write = True``
11257+
1116411258
Returns
1116511259
-------
1116611260
type of caller
@@ -11317,6 +11411,18 @@ def tz_convert(
1131711411
copy : bool, default True
1131811412
Also make a copy of the underlying data.
1131911413
11414+
.. note::
11415+
The `copy` keyword will change behavior in pandas 3.0.
11416+
`Copy-on-Write
11417+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
11418+
will be enabled by default, which means that all methods with a
11419+
`copy` keyword will use a lazy copy mechanism to defer the copy and
11420+
ignore the `copy` keyword. The `copy` keyword will be removed in a
11421+
future version of pandas.
11422+
11423+
You can already get the future behavior and improvements through
11424+
enabling copy on write ``pd.options.mode.copy_on_write = True``
11425+
1132011426
Returns
1132111427
-------
1132211428
{klass}
@@ -11406,6 +11512,18 @@ def tz_localize(
1140611512
must be None.
1140711513
copy : bool, default True
1140811514
Also make a copy of the underlying data.
11515+
11516+
.. note::
11517+
The `copy` keyword will change behavior in pandas 3.0.
11518+
`Copy-on-Write
11519+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
11520+
will be enabled by default, which means that all methods with a
11521+
`copy` keyword will use a lazy copy mechanism to defer the copy and
11522+
ignore the `copy` keyword. The `copy` keyword will be removed in a
11523+
future version of pandas.
11524+
11525+
You can already get the future behavior and improvements through
11526+
enabling copy on write ``pd.options.mode.copy_on_write = True``
1140911527
ambiguous : 'infer', bool-ndarray, 'NaT', default 'raise'
1141011528
When clocks moved backward due to DST, ambiguous times may arise.
1141111529
For example in Central European Time (UTC+01), when going from

pandas/core/series.py

+49-1
Original file line numberDiff line numberDiff line change
@@ -4314,7 +4314,19 @@ def nsmallest(
43144314
klass=_shared_doc_kwargs["klass"],
43154315
extra_params=dedent(
43164316
"""copy : bool, default True
4317-
Whether to copy underlying data."""
4317+
Whether to copy underlying data.
4318+
4319+
.. note::
4320+
The `copy` keyword will change behavior in pandas 3.0.
4321+
`Copy-on-Write
4322+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
4323+
will be enabled by default, which means that all methods with a
4324+
`copy` keyword will use a lazy copy mechanism to defer the copy and
4325+
ignore the `copy` keyword. The `copy` keyword will be removed in a
4326+
future version of pandas.
4327+
4328+
You can already get the future behavior and improvements through
4329+
enabling copy on write ``pd.options.mode.copy_on_write = True``"""
43184330
),
43194331
examples=dedent(
43204332
"""\
@@ -4967,6 +4979,18 @@ def rename(
49674979
Unused. Parameter needed for compatibility with DataFrame.
49684980
copy : bool, default True
49694981
Also copy underlying data.
4982+
4983+
.. note::
4984+
The `copy` keyword will change behavior in pandas 3.0.
4985+
`Copy-on-Write
4986+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
4987+
will be enabled by default, which means that all methods with a
4988+
`copy` keyword will use a lazy copy mechanism to defer the copy and
4989+
ignore the `copy` keyword. The `copy` keyword will be removed in a
4990+
future version of pandas.
4991+
4992+
You can already get the future behavior and improvements through
4993+
enabling copy on write ``pd.options.mode.copy_on_write = True``
49704994
inplace : bool, default False
49714995
Whether to return a new Series. If True the value of copy is ignored.
49724996
level : int or level name, default None
@@ -5751,6 +5775,18 @@ def to_timestamp(
57515775
copy : bool, default True
57525776
Whether or not to return a copy.
57535777
5778+
.. note::
5779+
The `copy` keyword will change behavior in pandas 3.0.
5780+
`Copy-on-Write
5781+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
5782+
will be enabled by default, which means that all methods with a
5783+
`copy` keyword will use a lazy copy mechanism to defer the copy and
5784+
ignore the `copy` keyword. The `copy` keyword will be removed in a
5785+
future version of pandas.
5786+
5787+
You can already get the future behavior and improvements through
5788+
enabling copy on write ``pd.options.mode.copy_on_write = True``
5789+
57545790
Returns
57555791
-------
57565792
Series with DatetimeIndex
@@ -5803,6 +5839,18 @@ def to_period(self, freq: str | None = None, copy: bool | None = None) -> Series
58035839
copy : bool, default True
58045840
Whether or not to return a copy.
58055841
5842+
.. note::
5843+
The `copy` keyword will change behavior in pandas 3.0.
5844+
`Copy-on-Write
5845+
<https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
5846+
will be enabled by default, which means that all methods with a
5847+
`copy` keyword will use a lazy copy mechanism to defer the copy and
5848+
ignore the `copy` keyword. The `copy` keyword will be removed in a
5849+
future version of pandas.
5850+
5851+
You can already get the future behavior and improvements through
5852+
enabling copy on write ``pd.options.mode.copy_on_write = True``
5853+
58065854
Returns
58075855
-------
58085856
Series

0 commit comments

Comments
 (0)