Skip to content

Commit

Permalink
BUG: Handle np strings in index.name in HDF pandas-dev#13492
Browse files Browse the repository at this point in the history
  • Loading branch information
makmanalp committed May 23, 2017
1 parent 49ec31b commit 48b91c5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ def _ensure_encoding(encoding):
return encoding


def _ensure_python_type(obj):
""" Ensure that non-python types get converted to python native type
equivalents."""
if isinstance(obj, np.generic):
return obj.item()
return obj


Term = Expr


Expand Down Expand Up @@ -2566,7 +2574,7 @@ def read_index_node(self, node, start=None, stop=None):
name = None

if 'name' in node._v_attrs:
name = node._v_attrs.name
name = _ensure_decoded(_ensure_python_type(node._v_attrs.name))

index_class = self._alias_to_class(getattr(node._v_attrs,
'index_class', ''))
Expand Down

0 comments on commit 48b91c5

Please sign in to comment.