wesm/pandas — Issue #492: Saving DataFrame with tuple index to HDFStore fails
Author: andreas-h
Created: 2011-12-15 08:52:27+00:00
State: open

The following code fails on pandas 0.6.1

```
import numpy as np
import pandas
col = np.arange(10)
idx = [(0.,1.), (2., 3.), (4., 5.)]
data = np.random.randn(30).reshape((3, 10))
DF = pandas.DataFrame(data, index=idx, columns=col)
H = pandas.HDFStore("test.h5", "w")
H['data'] = DF
H.close()
```

The traceback is as follows:

```
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/home2/hilboll/ in ()
----> 1 H['data'] = DF

/home2/hilboll/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in __setitem__(self, key, value)
121
122 def __setitem__(self, key, value):
--> 123 self.put(key, value)
124
125 def __len__(self):

/home2/hilboll/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in put(self, key, value, table, append, compression)
259 """
260 self._write_to_group(key, value, table=table, append=append,
--> 261 comp=compression)
262
263 def _get_handler(self, op, kind):

/home2/hilboll/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in _write_to_group(self, key, value, table, append, comp)
327 wrapper = lambda value: handler(group, value)
328
--> 329 wrapper(value)
330 group._v_attrs.pandas_type = kind
331

/home2/hilboll/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in (value)
325
326 handler = self._get_handler(op='write', kind=kind)
--> 327 wrapper = lambda value: handler(group, value)
328
329 wrapper(value)

/home2/hilboll/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in _write_frame(self, group, df)
336
337 def _write_frame(self, group, df):
--> 338 self._write_block_manager(group, df._data)
339
340 def _read_frame(self, group, where=None):

/home2/hilboll/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in _write_block_manager(self, group, data)
347 group._v_attrs.ndim = data.ndim
348 for i, ax in enumerate(data.axes):
--> 349 self._write_index(group, 'axis%d' % i, ax)
350
351 # Supporting mixed-type DataFrame objects...nontrivial

/home2/hilboll/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in _write_index(self, group, key, index)
439 else:
440 setattr(group._v_attrs, '%s_variety' % key, 'regular')
--> 441 converted, kind, _ = _convert_index(index)
442 self._write_array(group, key, converted)
443 node = getattr(group, key)

/home2/hilboll/.virtualenvs/pydoas/lib/python2.7/site-packages/pandas/io/pytables.pyc in _convert_index(index)
734 return np.asarray(values, dtype=np.float64), 'float', atom
735 else: # pragma: no cover
--> 736 raise ValueError('unrecognized index type %s' % type(values[0]))
737
738 def _read_array(group, key):

ValueError: unrecognized index type
```