357
357
of a string to indicate that the column name from `left` or
358
358
`right` should be left as-is, with no suffix. At least one of the
359
359
values must not be None.
360
- copy : bool, default True
360
+ copy : bool, default False
361
361
If False, avoid copy if possible.
362
362
363
363
.. note::
371
371
372
372
You can already get the future behavior and improvements through
373
373
enabling copy on write ``pd.options.mode.copy_on_write = True``
374
+
375
+ .. deprecated:: 3.0.0
374
376
indicator : bool or str, default False
375
377
If True, adds a column to the output DataFrame called "_merge" with
376
378
information on the source of each row. The column can be given a different
@@ -3576,7 +3578,11 @@ def memory_usage(self, index: bool = True, deep: bool = False) -> Series:
3576
3578
result = index_memory_usage ._append (result )
3577
3579
return result
3578
3580
3579
- def transpose (self , * args , copy : bool = False ) -> DataFrame :
3581
+ def transpose (
3582
+ self ,
3583
+ * args ,
3584
+ copy : bool | lib .NoDefault = lib .no_default ,
3585
+ ) -> DataFrame :
3580
3586
"""
3581
3587
Transpose index and columns.
3582
3588
@@ -3607,6 +3613,8 @@ def transpose(self, *args, copy: bool = False) -> DataFrame:
3607
3613
You can already get the future behavior and improvements through
3608
3614
enabling copy on write ``pd.options.mode.copy_on_write = True``
3609
3615
3616
+ .. deprecated:: 3.0.0
3617
+
3610
3618
Returns
3611
3619
-------
3612
3620
DataFrame
@@ -3687,6 +3695,7 @@ def transpose(self, *args, copy: bool = False) -> DataFrame:
3687
3695
1 object
3688
3696
dtype: object
3689
3697
"""
3698
+ self ._check_copy_deprecation (copy )
3690
3699
nv .validate_transpose (args , {})
3691
3700
# construct the args
3692
3701
@@ -5062,9 +5071,9 @@ def set_axis(
5062
5071
labels ,
5063
5072
* ,
5064
5073
axis : Axis = 0 ,
5065
- copy : bool | None = None ,
5074
+ copy : bool | lib . NoDefault = lib . no_default ,
5066
5075
) -> DataFrame :
5067
- return super ().set_axis (labels , axis = axis )
5076
+ return super ().set_axis (labels , axis = axis , copy = copy )
5068
5077
5069
5078
@doc (
5070
5079
NDFrame .reindex ,
@@ -5313,7 +5322,7 @@ def rename(
5313
5322
index : Renamer | None = ...,
5314
5323
columns : Renamer | None = ...,
5315
5324
axis : Axis | None = ...,
5316
- copy : bool | None = ... ,
5325
+ copy : bool | lib . NoDefault = lib . no_default ,
5317
5326
inplace : Literal [True ],
5318
5327
level : Level = ...,
5319
5328
errors : IgnoreRaise = ...,
@@ -5327,7 +5336,7 @@ def rename(
5327
5336
index : Renamer | None = ...,
5328
5337
columns : Renamer | None = ...,
5329
5338
axis : Axis | None = ...,
5330
- copy : bool | None = ... ,
5339
+ copy : bool | lib . NoDefault = lib . no_default ,
5331
5340
inplace : Literal [False ] = ...,
5332
5341
level : Level = ...,
5333
5342
errors : IgnoreRaise = ...,
@@ -5341,7 +5350,7 @@ def rename(
5341
5350
index : Renamer | None = ...,
5342
5351
columns : Renamer | None = ...,
5343
5352
axis : Axis | None = ...,
5344
- copy : bool | None = ... ,
5353
+ copy : bool | lib . NoDefault = lib . no_default ,
5345
5354
inplace : bool = ...,
5346
5355
level : Level = ...,
5347
5356
errors : IgnoreRaise = ...,
@@ -5354,7 +5363,7 @@ def rename(
5354
5363
index : Renamer | None = None ,
5355
5364
columns : Renamer | None = None ,
5356
5365
axis : Axis | None = None ,
5357
- copy : bool | None = None ,
5366
+ copy : bool | lib . NoDefault = lib . no_default ,
5358
5367
inplace : bool = False ,
5359
5368
level : Level | None = None ,
5360
5369
errors : IgnoreRaise = "ignore" ,
@@ -5384,7 +5393,7 @@ def rename(
5384
5393
axis : {0 or 'index', 1 or 'columns'}, default 0
5385
5394
Axis to target with ``mapper``. Can be either the axis name
5386
5395
('index', 'columns') or number (0, 1). The default is 'index'.
5387
- copy : bool, default True
5396
+ copy : bool, default False
5388
5397
Also copy underlying data.
5389
5398
5390
5399
.. note::
@@ -5398,6 +5407,8 @@ def rename(
5398
5407
5399
5408
You can already get the future behavior and improvements through
5400
5409
enabling copy on write ``pd.options.mode.copy_on_write = True``
5410
+
5411
+ .. deprecated:: 3.0.0
5401
5412
inplace : bool, default False
5402
5413
Whether to modify the DataFrame rather than creating a new one.
5403
5414
If True then value of copy is ignored.
@@ -5478,6 +5489,7 @@ def rename(
5478
5489
2 2 5
5479
5490
4 3 6
5480
5491
"""
5492
+ self ._check_copy_deprecation (copy )
5481
5493
return super ()._rename (
5482
5494
mapper = mapper ,
5483
5495
index = index ,
@@ -10657,10 +10669,12 @@ def merge(
10657
10669
right_index : bool = False ,
10658
10670
sort : bool = False ,
10659
10671
suffixes : Suffixes = ("_x" , "_y" ),
10660
- copy : bool | None = None ,
10672
+ copy : bool | lib . NoDefault = lib . no_default ,
10661
10673
indicator : str | bool = False ,
10662
10674
validate : MergeValidate | None = None ,
10663
10675
) -> DataFrame :
10676
+ self ._check_copy_deprecation (copy )
10677
+
10664
10678
from pandas .core .reshape .merge import merge
10665
10679
10666
10680
return merge (
@@ -12462,7 +12476,7 @@ def to_timestamp(
12462
12476
freq : Frequency | None = None ,
12463
12477
how : ToTimestampHow = "start" ,
12464
12478
axis : Axis = 0 ,
12465
- copy : bool | None = None ,
12479
+ copy : bool | lib . NoDefault = lib . no_default ,
12466
12480
) -> DataFrame :
12467
12481
"""
12468
12482
Cast to DatetimeIndex of timestamps, at *beginning* of period.
@@ -12476,7 +12490,7 @@ def to_timestamp(
12476
12490
vs. end.
12477
12491
axis : {0 or 'index', 1 or 'columns'}, default 0
12478
12492
The axis to convert (the index by default).
12479
- copy : bool, default True
12493
+ copy : bool, default False
12480
12494
If False then underlying input data is not copied.
12481
12495
12482
12496
.. note::
@@ -12491,6 +12505,8 @@ def to_timestamp(
12491
12505
You can already get the future behavior and improvements through
12492
12506
enabling copy on write ``pd.options.mode.copy_on_write = True``
12493
12507
12508
+ .. deprecated:: 3.0.0
12509
+
12494
12510
Returns
12495
12511
-------
12496
12512
DataFrame
@@ -12527,6 +12543,7 @@ def to_timestamp(
12527
12543
>>> df2.index
12528
12544
DatetimeIndex(['2023-01-31', '2024-01-31'], dtype='datetime64[ns]', freq=None)
12529
12545
"""
12546
+ self ._check_copy_deprecation (copy )
12530
12547
new_obj = self .copy (deep = False )
12531
12548
12532
12549
axis_name = self ._get_axis_name (axis )
@@ -12540,7 +12557,10 @@ def to_timestamp(
12540
12557
return new_obj
12541
12558
12542
12559
def to_period (
12543
- self , freq : Frequency | None = None , axis : Axis = 0 , copy : bool | None = None
12560
+ self ,
12561
+ freq : Frequency | None = None ,
12562
+ axis : Axis = 0 ,
12563
+ copy : bool | lib .NoDefault = lib .no_default ,
12544
12564
) -> DataFrame :
12545
12565
"""
12546
12566
Convert DataFrame from DatetimeIndex to PeriodIndex.
@@ -12554,7 +12574,7 @@ def to_period(
12554
12574
Frequency of the PeriodIndex.
12555
12575
axis : {0 or 'index', 1 or 'columns'}, default 0
12556
12576
The axis to convert (the index by default).
12557
- copy : bool, default True
12577
+ copy : bool, default False
12558
12578
If False then underlying input data is not copied.
12559
12579
12560
12580
.. note::
@@ -12569,6 +12589,8 @@ def to_period(
12569
12589
You can already get the future behavior and improvements through
12570
12590
enabling copy on write ``pd.options.mode.copy_on_write = True``
12571
12591
12592
+ .. deprecated:: 3.0.0
12593
+
12572
12594
Returns
12573
12595
-------
12574
12596
DataFrame
@@ -12596,6 +12618,7 @@ def to_period(
12596
12618
>>> idx.to_period("Y")
12597
12619
PeriodIndex(['2001', '2002', '2003'], dtype='period[Y-DEC]')
12598
12620
"""
12621
+ self ._check_copy_deprecation (copy )
12599
12622
new_obj = self .copy (deep = False )
12600
12623
12601
12624
axis_name = self ._get_axis_name (axis )
0 commit comments