Skip to content

Backport PR #31017 on branch 1.0.x (REG: restore format_type attr) #31206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions pandas/tests/io/pytables/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down