From 1c958dd1255668563db68e2ffc20cbc8241859ed Mon Sep 17 00:00:00 2001 From: Rafael Irgolic Date: Sat, 10 Jul 2021 01:25:15 +0100 Subject: [PATCH] add copy tests --- pandas/tests/frame/test_constructors.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py index 1d286e379da86..a76f786ffa52a 100644 --- a/pandas/tests/frame/test_constructors.py +++ b/pandas/tests/frame/test_constructors.py @@ -2868,3 +2868,13 @@ def test_tzaware_data_tznaive_dtype(self, constructor): assert np.all(result.dtypes == "M8[ns]") assert np.all(result == ts_naive) + + def test_1d_object_array_does_not_copy(self): + a = np.array(["a", "b"], dtype="object") + df = DataFrame(a, copy=False) + assert np.shares_memory(df.values, a) + + def test_2d_object_array_does_not_copy(self): + b = np.array([["a", "b"], ["c", "d"]], dtype="object") + df2 = DataFrame(b, copy=False) + assert np.shares_memory(df2.values, b)