Skip to content

Commit 47d85b3

Browse files
committed
Fix copy array manager
1 parent cead228 commit 47d85b3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pandas/core/internals/array_manager.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ def astype(self: T, dtype, copy: bool | None = False, errors: str = "raise") ->
375375
return self.apply(astype_array_safe, dtype=dtype, copy=copy, errors=errors)
376376

377377
def convert(self: T, copy: bool | None) -> T:
378+
if copy is None:
379+
copy = True
380+
378381
def _convert(arr):
379382
if is_object_dtype(arr.dtype):
380383
# extract PandasArray for tests that patch PandasArray._typ
@@ -386,11 +389,11 @@ def _convert(arr):
386389
convert_period=True,
387390
convert_interval=True,
388391
)
389-
if result is arr and (copy or copy is None):
392+
if result is arr and copy:
390393
return arr.copy()
391394
return result
392395
else:
393-
return arr.copy() if (copy or copy is None) else arr
396+
return arr.copy() if copy else arr
394397

395398
return self.apply(_convert)
396399

0 commit comments

Comments
 (0)