Skip to content

Commit d0c02fb

Browse files
BUG: Fix regression in to_hdf with MultiIndex and StringDtype (GH#63412)
1 parent c80c8ef commit d0c02fb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pandas/io/pytables.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,9 +3148,13 @@ def write_multi_index(self, key: str, index: MultiIndex) -> None:
31483148
):
31493149
# write the level
31503150
if isinstance(lev.dtype, ExtensionDtype):
3151-
raise NotImplementedError(
3152-
"Saving a MultiIndex with an extension dtype is not supported."
3153-
)
3151+
# GH 63412
3152+
if isinstance(lev.dtype, StringDtype):
3153+
lev = lev.astype(object)
3154+
else:
3155+
raise NotImplementedError(
3156+
"Saving a MultiIndex with an extension dtype is not supported."
3157+
)
31543158
level_key = f"{key}_level{i}"
31553159
conv_level = _convert_index(level_key, lev, self.encoding, self.errors)
31563160
self.write_array(level_key, conv_level.values)

0 commit comments

Comments
 (0)