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

Function test_api_default_format_path

pandas/tests/io/pytables/test_put.py:67–88  ·  view source on GitHub ↗
(temp_h5_path)

Source from the content-addressed store, hash-verified

65
66
67def test_api_default_format_path(temp_h5_path):
68 df = DataFrame(
69 1.1 * np.arange(120).reshape((30, 4)),
70 columns=Index(list("ABCD")),
71 index=Index([f"i-{i}" for i in range(30)]),
72 )
73
74 with pd.option_context("io.hdf.default_format", "fixed"):
75 df.to_hdf(temp_h5_path, key="df")
76 with HDFStore(temp_h5_path) as store:
77 assert not store.get_storer("df").is_table
78 msg = "Can only append to Tables"
79 with pytest.raises(ValueError, match=msg):
80 df.to_hdf(temp_h5_path, key="df2", append=True)
81
82 with pd.option_context("io.hdf.default_format", "table"):
83 df.to_hdf(temp_h5_path, key="df3")
84 with HDFStore(temp_h5_path) as store:
85 assert store.get_storer("df3").is_table
86 df.to_hdf(temp_h5_path, key="df4", append=True)
87 with HDFStore(temp_h5_path) as store:
88 assert store.get_storer("df4").is_table
89
90
91def test_put(temp_hdfstore):

Callers

nothing calls this directly

Calls 7

DataFrameClass · 0.90
IndexClass · 0.90
HDFStoreClass · 0.90
to_hdfMethod · 0.80
get_storerMethod · 0.80
reshapeMethod · 0.45
raisesMethod · 0.45

Tested by

no test coverage detected