Skip to content

Commit

Permalink
TST: add test case for PeriodIndex in HDFStore(GH7796) (#48618)
Browse files Browse the repository at this point in the history
* TST: add test case for PeriodIndex in HDFStore

* TST: add test case for PeriodIndex in HDFStore

* use pytest.mark.parameterize instead
  • Loading branch information
paradox-lab authored Sep 20, 2022
1 parent 7007ad8 commit 658b2b8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pandas/tests/io/pytables/test_put.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,17 @@ def make_index(names=None):
)
store.append("df", df)
tm.assert_frame_equal(store.select("df"), df)


@pytest.mark.parametrize("format", ["fixed", "table"])
def test_store_periodindex(setup_path, format):
# GH 7796
# test of PeriodIndex in HDFStore
df = DataFrame(
np.random.randn(5, 1), index=pd.period_range("20220101", freq="M", periods=5)
)

with ensure_clean_path(setup_path) as path:
df.to_hdf(path, "df", mode="w", format=format)
expected = pd.read_hdf(path, "df")
tm.assert_frame_equal(df, expected)

0 comments on commit 658b2b8

Please sign in to comment.