HDFStore updating stored HDF5 python pandas dataframe

Viewed 3374

I have two dataframes, df1 which is stored in a pd.HDFStore object and the other which is to be appended to the dataframe.

store = pd.HDFStore('dataframe_store.h5')

df1 = pd.DataFrame(np.empty((100, 5)))
df2 = pd.DataFrame(np.empty((100, 5)))

store['df1'] = df1

Effectively, I would like the end result to be equal to ...

store['df1'] = df1.append(df2)

I would like to append df2 to the stored df1, rather completely overwrite the HDFStore object with a new dataframe. Is this possible?

Furthermore, when I run the following code I return ValueError can only append to Tables... why is this?

df = pd.DataFrame(np.empty((1000, 5)))
df2 = pd.DataFrame(np.empty((1000, 5)))

store = pd.HDFStore('store.h5')

store['df'] = df

store.append('df', df2)
1 Answers
Related