Skip to content

Commit 8fc9d7d

Browse files
committed
Merge pull request #3126 from jreback/hdf_bug
BUG: HDFStore bug when appending to a table, .typ not recreated on subsequent appends
2 parents 2349915 + c82d7e2 commit 8fc9d7d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

pandas/io/pytables.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,10 @@ def set_kind(self):
11621162
elif self.dtype.startswith('bool'):
11631163
self.kind = 'bool'
11641164

1165+
# set my typ if we need
1166+
if self.typ is None:
1167+
self.typ = getattr(self.description,self.cname,None)
1168+
11651169
def set_atom(self, block, existing_col, min_itemsize, nan_rep, **kwargs):
11661170
""" create and setup my atom from the block b """
11671171

pandas/io/tests/test_pytables.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,15 @@ def check_col(key,name,size):
659659
result = store.select('df')
660660
tm.assert_frame_equal(result, df)
661661

662+
with ensure_clean(self.path) as store:
663+
664+
# infer the .typ on subsequent appends
665+
df = DataFrame(dict(A = 'foo', B = 'bar'),index=range(10))
666+
store.remove('df')
667+
store.append('df', df[:5], min_itemsize=200)
668+
store.append('df', df[5:], min_itemsize=200)
669+
tm.assert_frame_equal(store['df'], df)
670+
662671
def test_append_with_data_columns(self):
663672

664673
with ensure_clean(self.path) as store:

0 commit comments

Comments
 (0)