Skip to content

Commit 230180c

Browse files
add test case for df copy=True
1 parent f1e7115 commit 230180c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/copy_view/test_array.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ def test_dataframe_multiple_numpy_dtypes():
141141
with pytest.raises(ValueError, match="Unable to avoid copy while creating"):
142142
arr = np.array(df, copy=False)
143143

144+
arr = np.array(df, copy=True)
145+
assert arr.flags.writeable is True
146+
147+
148+
def test_dataframe_single_block_copy_true():
149+
# the copy=False/None cases are tested above in test_dataframe_values
150+
df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
151+
arr = np.array(df, copy=True)
152+
assert not np.shares_memory(arr, get_array(df, "a"))
153+
assert arr.flags.writeable is True
154+
144155

145156
def test_values_is_ea():
146157
df = DataFrame({"a": date_range("2012-01-01", periods=3)})

0 commit comments

Comments
 (0)