Skip to content

Commit 8848692

Browse files
authored
CoW: Enforce some deprecations on the block level (#57253)
1 parent 266bd4c commit 8848692

File tree

5 files changed

+94
-180
lines changed

5 files changed

+94
-180
lines changed

pandas/core/frame.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10744,7 +10744,6 @@ def _series_round(ser: Series, decimals: int) -> Series:
1074410744
# type "Union[int, integer[Any]]"; expected "int"
1074510745
new_mgr = self._mgr.round(
1074610746
decimals=decimals, # type: ignore[arg-type]
10747-
using_cow=using_copy_on_write(),
1074810747
)
1074910748
return self._constructor_from_mgr(new_mgr, axes=new_mgr.axes).__finalize__(
1075010749
self, method="round"

pandas/core/generic.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6360,9 +6360,6 @@ def astype(
63606360
2 2020-01-03
63616361
dtype: datetime64[ns]
63626362
"""
6363-
if copy and using_copy_on_write():
6364-
copy = False
6365-
63666363
if is_dict_like(dtype):
63676364
if self.ndim == 1: # i.e. Series
63686365
if len(dtype) > 1 or self.name not in dtype:
@@ -6371,7 +6368,7 @@ def astype(
63716368
"the key in Series dtype mappings."
63726369
)
63736370
new_type = dtype[self.name]
6374-
return self.astype(new_type, copy, errors)
6371+
return self.astype(new_type, errors=errors)
63756372

63766373
# GH#44417 cast to Series so we can use .iat below, which will be
63776374
# robust in case we
@@ -6393,10 +6390,10 @@ def astype(
63936390
for i, (col_name, col) in enumerate(self.items()):
63946391
cdt = dtype_ser.iat[i]
63956392
if isna(cdt):
6396-
res_col = col.copy(deep=copy)
6393+
res_col = col.copy(deep=False)
63976394
else:
63986395
try:
6399-
res_col = col.astype(dtype=cdt, copy=copy, errors=errors)
6396+
res_col = col.astype(dtype=cdt, errors=errors)
64006397
except ValueError as ex:
64016398
ex.args = (
64026399
f"{ex}: Error while type casting for column '{col_name}'",
@@ -6410,22 +6407,20 @@ def astype(
64106407
if isinstance(dtype, ExtensionDtype) and all(
64116408
arr.dtype == dtype for arr in self._mgr.arrays
64126409
):
6413-
return self.copy(deep=copy)
6410+
return self.copy(deep=False)
64146411
# GH 18099/22869: columnwise conversion to extension dtype
64156412
# GH 24704: self.items handles duplicate column names
6416-
results = [
6417-
ser.astype(dtype, copy=copy, errors=errors) for _, ser in self.items()
6418-
]
6413+
results = [ser.astype(dtype, errors=errors) for _, ser in self.items()]
64196414

64206415
else:
64216416
# else, only a single dtype is given
6422-
new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors)
6417+
new_data = self._mgr.astype(dtype=dtype, errors=errors)
64236418
res = self._constructor_from_mgr(new_data, axes=new_data.axes)
64246419
return res.__finalize__(self, method="astype")
64256420

64266421
# GH 33113: handle empty frame or series
64276422
if not results:
6428-
return self.copy(deep=None)
6423+
return self.copy(deep=False)
64296424

64306425
# GH 19920: retain column metadata after concat
64316426
result = concat(results, axis=1, copy=False)

0 commit comments

Comments
 (0)