Skip to content

Commit

Permalink
BUG: pickle all other index types, re: #492
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed Dec 15, 2011
1 parent 2babd1b commit ff73455
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,8 @@ def _convert_index(index):
atom = _tables().Float64Col()
return np.asarray(values, dtype=np.float64), 'float', atom
else: # pragma: no cover
raise ValueError('unrecognized index type %s' % type(values[0]))
atom = _tables().ObjectAtom()
return np.asarray(values, dtype='O'), 'object', atom

def _read_array(group, key):
import tables
Expand All @@ -755,6 +756,8 @@ def _unconvert_index(data, kind):

elif kind in ('string', 'integer', 'float'):
index = np.array(data)
elif kind == 'object':
index = np.array(data[0])
else: # pragma: no cover
raise ValueError('unrecognized index type %s' % kind)
return index
Expand Down
8 changes: 8 additions & 0 deletions pandas/io/tests/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ def test_float_index(self):
s = Series(np.random.randn(10), index=index)
self._check_roundtrip(s, tm.assert_series_equal)

def test_tuple_index(self):
# GH #492
col = np.arange(10)
idx = [(0.,1.), (2., 3.), (4., 5.)]
data = np.random.randn(30).reshape((3, 10))
DF = DataFrame(data, index=idx, columns=col)
self._check_roundtrip(DF, tm.assert_frame_equal)

def test_timeseries_preepoch(self):
if sys.version_info[0] == 2 and sys.version_info[1] < 7:
raise nose.SkipTest
Expand Down

0 comments on commit ff73455

Please sign in to comment.