File tree 2 files changed +17
-8
lines changed
2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change 54
54
)
55
55
56
56
import pandas .core .algorithms as algos
57
- from pandas .core .arrays import DatetimeArray
57
+ from pandas .core .arrays import (
58
+ ArrowExtensionArray ,
59
+ ArrowStringArray ,
60
+ DatetimeArray ,
61
+ )
58
62
from pandas .core .arrays ._mixins import NDArrayBackedExtensionArray
59
63
from pandas .core .construction import (
60
64
ensure_wrapped_if_datetimelike ,
@@ -1343,11 +1347,15 @@ def column_setitem(
1343
1347
intermediate Series at the DataFrame level (`s = df[loc]; s[idx] = value`)
1344
1348
"""
1345
1349
if warn_copy_on_write () and not self ._has_no_reference (loc ):
1346
- warnings .warn (
1347
- COW_WARNING_GENERAL_MSG ,
1348
- FutureWarning ,
1349
- stacklevel = find_stack_level (),
1350
- )
1350
+ if not isinstance (
1351
+ self .blocks [self .blknos [loc ]].values ,
1352
+ (ArrowExtensionArray , ArrowStringArray ),
1353
+ ):
1354
+ warnings .warn (
1355
+ COW_WARNING_GENERAL_MSG ,
1356
+ FutureWarning ,
1357
+ stacklevel = find_stack_level (),
1358
+ )
1351
1359
elif using_copy_on_write () and not self ._has_no_reference (loc ):
1352
1360
blkno = self .blknos [loc ]
1353
1361
# Split blocks to only copy the column we want to modify
Original file line number Diff line number Diff line change @@ -344,8 +344,9 @@ def test_fillna_inplace_ea_noop_shares_memory(
344
344
assert not df ._mgr ._has_no_reference (1 )
345
345
assert not view ._mgr ._has_no_reference (1 )
346
346
347
- # TODO(CoW-warn) should this warn for ArrowDtype?
348
- with tm .assert_cow_warning (warn_copy_on_write ):
347
+ with tm .assert_cow_warning (
348
+ warn_copy_on_write and "pyarrow" not in any_numeric_ea_and_arrow_dtype
349
+ ):
349
350
df .iloc [0 , 1 ] = 100
350
351
if isinstance (df ["a" ].dtype , ArrowDtype ) or using_copy_on_write :
351
352
tm .assert_frame_equal (df_orig , view )
You can’t perform that action at this time.
0 commit comments