Skip to content

Commit a0b59f8

Browse files
committed
BUG: prevent segfault since MultiIndex not supported in HDF5 table format. close #1848
1 parent b66dc9c commit a0b59f8

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

RELEASE.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ pandas 0.9.0
122122
- Fix bug in DataFrame.duplicated with datetime64 columns (#1833)
123123
- Fix bug in Panel internals resulting in error when doing fillna after
124124
truncate not changing size of panel (#1823)
125+
- Prevent segfault due to MultiIndex not being supported in HDFStore table
126+
format (#1848)
125127

126128
pandas 0.8.1
127129
============

pandas/io/pytables.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,9 @@ def _convert_index(index):
931931
atom = _tables().Int64Col()
932932
return index.values, 'integer', atom
933933

934+
if isinstance(index, MultiIndex):
935+
raise Exception('MultiIndex not supported here!')
936+
934937
inferred_type = lib.infer_dtype(index)
935938

936939
values = np.asarray(index)

pandas/io/tests/test_pytables.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,14 @@ def test_store_datetime_mixed(self):
677677
df['d'] = ts.index[:3]
678678
self._check_roundtrip(df, tm.assert_frame_equal)
679679

680+
def test_cant_write_multiindex_table(self):
681+
# for now, #1848
682+
df = DataFrame(np.random.randn(10, 4),
683+
index=[np.arange(5).repeat(2),
684+
np.tile(np.arange(2), 5)])
685+
686+
self.assertRaises(Exception, self.store.put, 'foo', df, table=True)
687+
680688
def curpath():
681689
pth, _ = os.path.split(os.path.abspath(__file__))
682690
return pth

0 commit comments

Comments
 (0)