Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
===========

Expand Down
2 changes: 1 addition & 1 deletion pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions pandas/io/tests/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down