Skip to content

Commit ff73455

Browse files
committed
BUG: pickle all other index types, re: #492
1 parent 2babd1b commit ff73455

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pandas/io/pytables.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,8 @@ def _convert_index(index):
733733
atom = _tables().Float64Col()
734734
return np.asarray(values, dtype=np.float64), 'float', atom
735735
else: # pragma: no cover
736-
raise ValueError('unrecognized index type %s' % type(values[0]))
736+
atom = _tables().ObjectAtom()
737+
return np.asarray(values, dtype='O'), 'object', atom
737738

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

756757
elif kind in ('string', 'integer', 'float'):
757758
index = np.array(data)
759+
elif kind == 'object':
760+
index = np.array(data[0])
758761
else: # pragma: no cover
759762
raise ValueError('unrecognized index type %s' % kind)
760763
return index

pandas/io/tests/test_pytables.py

+8
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ def test_float_index(self):
179179
s = Series(np.random.randn(10), index=index)
180180
self._check_roundtrip(s, tm.assert_series_equal)
181181

182+
def test_tuple_index(self):
183+
# GH #492
184+
col = np.arange(10)
185+
idx = [(0.,1.), (2., 3.), (4., 5.)]
186+
data = np.random.randn(30).reshape((3, 10))
187+
DF = DataFrame(data, index=idx, columns=col)
188+
self._check_roundtrip(DF, tm.assert_frame_equal)
189+
182190
def test_timeseries_preepoch(self):
183191
if sys.version_info[0] == 2 and sys.version_info[1] < 7:
184192
raise nose.SkipTest

0 commit comments

Comments
 (0)