MCPcopy
hub / github.com/pandas-dev/pandas / test_items

Function test_items

pandas/tests/copy_view/test_methods.py:1104–1118  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1102
1103
1104def 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"])

Callers

nothing calls this directly

Calls 4

itemsMethod · 0.95
DataFrameClass · 0.90
get_arrayFunction · 0.90
copyMethod · 0.45

Tested by

no test coverage detected