From a323b2543449d33ba3696dfbfa968167d4f2749b Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Wed, 22 Jan 2020 06:16:45 -0800 Subject: [PATCH] Backport PR #31017: REG: restore format_type attr --- pandas/io/pytables.py | 2 ++ pandas/tests/io/pytables/test_store.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index d61d1cf7f0257..4f12c0225bd2d 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -2474,6 +2474,7 @@ class Fixed: """ pandas_kind: str + format_type: str = "fixed" # GH#30962 needed by dask obj_type: Type[Union[DataFrame, Series]] ndim: int encoding: str @@ -3132,6 +3133,7 @@ class Table(Fixed): """ pandas_kind = "wide_table" + format_type: str = "table" # GH#30962 needed by dask table_type: str levels = 1 is_table = True diff --git a/pandas/tests/io/pytables/test_store.py b/pandas/tests/io/pytables/test_store.py index 64c4ad800f49d..f56d042093886 100644 --- a/pandas/tests/io/pytables/test_store.py +++ b/pandas/tests/io/pytables/test_store.py @@ -64,6 +64,16 @@ @pytest.mark.single class TestHDFStore: + def test_format_type(self, setup_path): + df = pd.DataFrame({"A": [1, 2]}) + with ensure_clean_path(setup_path) as path: + with HDFStore(path) as store: + store.put("a", df, format="fixed") + store.put("b", df, format="table") + + assert store.get_storer("a").format_type == "fixed" + assert store.get_storer("b").format_type == "table" + def test_format_kwarg_in_constructor(self, setup_path): # GH 13291