Skip to content

Commit 586fe06

Browse files
committed
Merge pull request #6167 from wabu/append-multi-fix
append to existing table with mulitindex fix
2 parents f26694c + 5d9c7ea commit 586fe06

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

doc/source/release.rst

+2
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ Bug Fixes
172172
string comparisons (:issue:`6155`).
173173
- Fixed a bug in ``query`` where the index of a single-element ``Series`` was
174174
being thrown away (:issue:`6148`).
175+
- Bug in ``HDFStore`` on appending a dataframe with multi-indexed columns to
176+
an existing table (:issue:`6167`)
175177

176178
pandas 0.13.0
177179
-------------

pandas/io/pytables.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3068,9 +3068,9 @@ def validate_data_columns(self, data_columns, min_itemsize):
30683068

30693069
axis, axis_labels = self.non_index_axes[0]
30703070
info = self.info.get(axis, dict())
3071-
if info.get('type') == 'MultiIndex' and data_columns is not None:
3071+
if info.get('type') == 'MultiIndex' and data_columns:
30723072
raise ValueError("cannot use a multi-index on axis [{0}] with "
3073-
"data_columns".format(axis))
3073+
"data_columns {1}".format(axis, data_columns))
30743074

30753075
# evaluate the passed data_columns, True == use all columns
30763076
# take only valide axis labels

pandas/io/tests/test_pytables.py

+7
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,13 @@ def test_column_multiindex(self):
16131613
self.assertRaises(ValueError, store.put, 'df2',df,format='table',data_columns=['A'])
16141614
self.assertRaises(ValueError, store.put, 'df3',df,format='table',data_columns=True)
16151615

1616+
# appending multi-column on existing table (see GH 6167)
1617+
with ensure_clean_store(self.path) as store:
1618+
store.append('df2', df)
1619+
store.append('df2', df)
1620+
1621+
tm.assert_frame_equal(store['df2'], concat((df,df)))
1622+
16161623
# non_index_axes name
16171624
df = DataFrame(np.arange(12).reshape(3,4), columns=Index(list('ABCD'),name='foo'))
16181625

0 commit comments

Comments
 (0)