Append data to HDF5 file with Pandas, Python

后端 未结 2 1083
再見小時候
再見小時候 2021-01-02 09:38

I have large pandas DataFrames with financial data. I have no problem appending and concatenating additional columns and DataFrames to my .h5 file.

The financial dat

2条回答
  •  星月不相逢
    2021-01-02 09:49

    pandas.HDFStore.put() has parameter append (which defaults to False) - that instructs Pandas to overwrite instead of appending.

    So try this:

    store = pd.HDFStore('test.h5')
    
    store.append('name_of_frame', ohlcv_candle, format='t',  data_columns=True)
    

    we can also use store.put(..., append=True), but this file should also be created in a table format:

    store.put('name_of_frame', ohlcv_candle, format='t', append=True, data_columns=True)
    

    NOTE: appending works only for the table (format='t' - is an alias for format='table') format.

提交回复
热议问题