diff --git a/doc/source/release.rst b/doc/source/release.rst index 55d0858ebbcde..54fa4d30bac0a 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -44,6 +44,9 @@ pandas 0.13 **Bug Fixes** + - ``HDFStore`` raising an invalid ``TypeError`` rather than ``ValueError`` when appending + with a different block ordering (:issue:`4096`) + pandas 0.12 =========== diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 3c08213bf26d1..a5a8355567e23 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -2672,7 +2672,7 @@ def create_axes(self, axes, obj, validate=True, nan_rep=None, data_columns=None, b = by_items.pop(items) new_blocks.append(b) except: - raise ValueError("cannot match existing table structure for [%s] on appending data" % items) + raise ValueError("cannot match existing table structure for [%s] on appending data" % ','.join(items)) blocks = new_blocks # add my values diff --git a/pandas/io/tests/test_pytables.py b/pandas/io/tests/test_pytables.py index 00d8089ad2ee7..6518f9cb6097f 100644 --- a/pandas/io/tests/test_pytables.py +++ b/pandas/io/tests/test_pytables.py @@ -620,6 +620,21 @@ def test_append_with_different_block_ordering(self): store.append('df',df) + # test a different ordering but with more fields (like invalid combinate) + with ensure_clean(self.path) as store: + + df = DataFrame(np.random.randn(10,2),columns=list('AB'), dtype='float64') + df['int64'] = Series([1]*len(df),dtype='int64') + df['int16'] = Series([1]*len(df),dtype='int16') + store.append('df',df) + + # store additonal fields in different blocks + df['int16_2'] = Series([1]*len(df),dtype='int16') + self.assertRaises(ValueError, store.append, 'df', df) + + # store multile additonal fields in different blocks + df['float_3'] = Series([1.]*len(df),dtype='float64') + self.assertRaises(ValueError, store.append, 'df', df) def test_ndim_indexables(self): """ test using ndim tables in new ways"""