I can convert a pandas dataframe to an HDF byte array like so:
data = ... # a pandas dataframe
with pd.HDFStore(
"in-memory-save-file",
mode="w",
driver="H5FD_CORE",
driver_core_backing_store=0,
) as store:
store.put("data", data, format="table")
bytes_to_write = store._handle.get_file_image()
bytes_to_write
now contains the DataFrame.
I need to convert this buffer back to a DataFrame.
The pandas.read_hdf
method accepts a pandas.HDFStore
, but this class seems like can only be constructed using a file path, not a buffer.
But how can I convert this byte array back to a DataFrame?
I'm on Python 3.9.
Any pointers are greatly appreciated!