Skip to content

Hdfstore alias #1236

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

Closed
wants to merge 2 commits into from
Closed
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
22 changes: 19 additions & 3 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,8 @@ def _write_index(self, group, key, index):
node._v_attrs.kind = kind
node._v_attrs.name = index.name

if isinstance(index, (DatetimeIndex, PeriodIndex, IntIndex)):
node._v_attrs.index_class = type(index)
if isinstance(index, (DatetimeIndex, PeriodIndex)):
node._v_attrs.index_class = _class_to_alias(type(index))

if hasattr(index, 'freq'):
node._v_attrs.freq = index.freq
Expand Down Expand Up @@ -667,7 +667,8 @@ def _read_index_node(self, node):
if 'name' in node._v_attrs:
name = node._v_attrs.name

index_class = getattr(node._v_attrs, 'index_class', Index)
index_class = _alias_to_class(getattr(node._v_attrs, 'index_class', ''))

kwargs = {}
if 'freq' in node._v_attrs:
kwargs['freq'] = node._v_attrs['freq']
Expand Down Expand Up @@ -1003,6 +1004,21 @@ def _is_table_type(group):
# new node, e.g.
return False

_index_type_map = {DatetimeIndex : 'datetime',
PeriodIndex : 'period'}

_reverse_index_map = {}
for k, v in _index_type_map.iteritems():
_reverse_index_map[v] = k

def _class_to_alias(cls):
return _index_type_map.get(cls, '')

def _alias_to_class(alias):
if isinstance(alias, type):
return alias
return _reverse_index_map.get(alias, Index)

class Selection(object):
"""
Carries out a selection operation on a tables.Table object.
Expand Down