diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 929d9182f35a9..fd9127efa72df 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -1162,6 +1162,10 @@ def set_kind(self): elif self.dtype.startswith('bool'): self.kind = 'bool' + # set my typ if we need + if self.typ is None: + self.typ = getattr(self.description,self.cname,None) + def set_atom(self, block, existing_col, min_itemsize, nan_rep, **kwargs): """ create and setup my atom from the block b """ diff --git a/pandas/io/tests/test_pytables.py b/pandas/io/tests/test_pytables.py index a40284ff1b1ae..158cb351678f3 100644 --- a/pandas/io/tests/test_pytables.py +++ b/pandas/io/tests/test_pytables.py @@ -659,6 +659,15 @@ def check_col(key,name,size): result = store.select('df') tm.assert_frame_equal(result, df) + with ensure_clean(self.path) as store: + + # infer the .typ on subsequent appends + df = DataFrame(dict(A = 'foo', B = 'bar'),index=range(10)) + store.remove('df') + store.append('df', df[:5], min_itemsize=200) + store.append('df', df[5:], min_itemsize=200) + tm.assert_frame_equal(store['df'], df) + def test_append_with_data_columns(self): with ensure_clean(self.path) as store: