Skip to content

Commit dbd8b4c

Browse files
committed
BUG: Handle np strings in index.name in HDF pandas-dev#13492
1 parent fb47ee5 commit dbd8b4c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pandas/io/pytables.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ def _ensure_encoding(encoding):
7373
return encoding
7474

7575

76+
def _ensure_python_type(obj):
77+
""" Ensure that non-python types get converted to python native type
78+
equivalents."""
79+
if isinstance(obj, np.generic):
80+
return obj.item()
81+
return obj
82+
83+
7684
Term = Expr
7785

7886

@@ -2567,7 +2575,7 @@ def read_index_node(self, node, start=None, stop=None):
25672575
name = None
25682576

25692577
if 'name' in node._v_attrs:
2570-
name = node._v_attrs.name
2578+
name = _ensure_decoded(_ensure_python_type(node._v_attrs.name))
25712579

25722580
index_class = self._alias_to_class(getattr(node._v_attrs,
25732581
'index_class', ''))

0 commit comments

Comments
 (0)