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

Function test_copy

pandas/tests/io/pytables/test_store.py:945–974  ·  view source on GitHub ↗
(propindexes, temp_file)

Source from the content-addressed store, hash-verified

943
944@pytest.mark.parametrize("propindexes", [True, False])
945def test_copy(propindexes, temp_file):
946 df = DataFrame(
947 1.1 * np.arange(120).reshape((30, 4)),
948 columns=Index(list("ABCD")),
949 index=Index([f"i-{i}" for i in range(30)]),
950 )
951
952 with HDFStore(temp_file) as st:
953 st.append("df", df, data_columns=["A"])
954 with tempfile.NamedTemporaryFile() as new_f:
955 with HDFStore(temp_file) as store:
956 with contextlib.closing(
957 store.copy(new_f.name, keys=None, propindexes=propindexes)
958 ) as tstore:
959 # check keys
960 keys = store.keys()
961 assert set(keys) == set(tstore.keys())
962 # check indices & nrows
963 for k in tstore.keys():
964 if tstore.get_storer(k).is_table:
965 new_t = tstore.get_storer(k)
966 orig_t = store.get_storer(k)
967
968 assert orig_t.nrows == new_t.nrows
969
970 # check propindixes
971 if propindexes:
972 for a in orig_t.axes:
973 if a.is_indexed:
974 assert new_t[a.name].is_indexed
975
976
977def test_duplicate_column_name(temp_h5_path):

Callers

nothing calls this directly

Calls 8

DataFrameClass · 0.90
IndexClass · 0.90
HDFStoreClass · 0.90
get_storerMethod · 0.80
reshapeMethod · 0.45
appendMethod · 0.45
copyMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected