diff --git a/pandas/core/computation/eval.py b/pandas/core/computation/eval.py index 55421090d4202..f3a82e268c732 100644 --- a/pandas/core/computation/eval.py +++ b/pandas/core/computation/eval.py @@ -378,7 +378,7 @@ def eval( try: target = env.target if isinstance(target, NDFrame): - target = target.copy(deep=None) + target = target.copy(deep=False) else: target = target.copy() except AttributeError as err: diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 7614951566bf9..f41e03b2129f0 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -7488,7 +7488,7 @@ def replace( if not self.size: if inplace: return None - return self.copy(deep=None) + return self.copy(deep=False) if is_dict_like(to_replace): if is_dict_like(value): # {'A' : NA} -> {'A' : 0} @@ -10281,7 +10281,7 @@ def shift( fill_value = lib.no_default if periods == 0: - return self.copy(deep=None) + return self.copy(deep=False) if is_list_like(periods) and isinstance(self, ABCSeries): return self.to_frame().shift( diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index 3cb7c72431613..f154054526898 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -702,7 +702,7 @@ def _combine(self, blocks: list[Block], index: Index | None = None) -> Self: def nblocks(self) -> int: return len(self.blocks) - def copy(self, deep: bool | None | Literal["all"] = True) -> Self: + def copy(self, deep: bool | Literal["all"] = True) -> Self: """ Make deep or shallow copy of BlockManager @@ -716,7 +716,6 @@ def copy(self, deep: bool | None | Literal["all"] = True) -> Self: ------- BlockManager """ - deep = deep if deep is not None else False # this preserves the notion of view copying of axes if deep: # hit in e.g. tests.io.json.test_pandas diff --git a/pandas/tests/copy_view/test_internals.py b/pandas/tests/copy_view/test_internals.py index 07447ab827cec..a4cb1e6bea9c9 100644 --- a/pandas/tests/copy_view/test_internals.py +++ b/pandas/tests/copy_view/test_internals.py @@ -70,7 +70,7 @@ def test_iset_splits_blocks_inplace(locs, arr, dtype): ) arr = arr.astype(dtype) df_orig = df.copy() - df2 = df.copy(deep=None) # Trigger a CoW (if enabled, otherwise makes copy) + df2 = df.copy(deep=False) # Trigger a CoW (if enabled, otherwise makes copy) df2._mgr.iset(locs, arr, inplace=True) tm.assert_frame_equal(df, df_orig) diff --git a/pandas/tests/copy_view/test_methods.py b/pandas/tests/copy_view/test_methods.py index e96899d155c54..05207e13c8547 100644 --- a/pandas/tests/copy_view/test_methods.py +++ b/pandas/tests/copy_view/test_methods.py @@ -1243,7 +1243,7 @@ def test_interpolate_creates_copy(): def test_isetitem(): df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6], "c": [7, 8, 9]}) df_orig = df.copy() - df2 = df.copy(deep=None) # Trigger a CoW + df2 = df.copy(deep=False) # Trigger a CoW df2.isetitem(1, np.array([-1, -2, -3])) # This is inplace assert np.shares_memory(get_array(df, "c"), get_array(df2, "c")) assert np.shares_memory(get_array(df, "a"), get_array(df2, "a"))