| 1102 | |
| 1103 | |
| 1104 | def test_items(): |
| 1105 | df = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6], "c": [7, 8, 9]}) |
| 1106 | df_orig = df.copy() |
| 1107 | |
| 1108 | # Test this twice, since the second time, the item cache will be |
| 1109 | # triggered, and we want to make sure it still works then. |
| 1110 | for i in range(2): |
| 1111 | for name, ser in df.items(): |
| 1112 | assert np.shares_memory(get_array(ser, name), get_array(df, name)) |
| 1113 | |
| 1114 | # mutating df triggers a copy-on-write for that column / block |
| 1115 | ser.iloc[0] = 0 |
| 1116 | |
| 1117 | assert not np.shares_memory(get_array(ser, name), get_array(df, name)) |
| 1118 | tm.assert_frame_equal(df, df_orig) |
| 1119 | |
| 1120 | |
| 1121 | @pytest.mark.parametrize("dtype", ["int64", "Int64"]) |