diff --git a/utils/df_utils.py b/utils/df_utils.py index d256b04..7114cf0 100644 --- a/utils/df_utils.py +++ b/utils/df_utils.py @@ -25,10 +25,20 @@ def to_excel_binary(df, **kwargs): res = out.getvalue() return res -def to_hdf_binary(df, key="df", **kwargs): - with BytesIO() as out: - df.to_hdf(out, key, **kwargs) - res = out.getvalue() + + +from pandas import HDFStore + + +def to_hdf_binary(df): + with HDFStore( + "wontbewritten.h5", + mode="a", + driver="H5FD_CORE", + driver_core_backing_store=0 + ) as out: + out["/data"] = df + res = out._handle.get_file_image() return res