Home > Back-end >  What did the HDF5 format do to the csv file?
What did the HDF5 format do to the csv file?

Time:08-10

I had a csv file of 33GB but after converting to HDF5 format the file size drastically reduced to around 1.4GB. I used vaex library to read my dataset and then converted this vaex dataframe to pandas dataframe. This conversion of vaex dataframe to pandas dataframe did not put too much load on my RAM.

I wanted to ask what this process (CSV-->HDF5-->pandas dataframe) did so that now pandas dataframe did not take up too much memory instead of when I was reading the pandas dataframe directly from CSV file (csv-->pandas dataframe)?

CodePudding user response:

  1. HDF5 compresses the data, that explains lower amount of disk space used.
  2. In terms of RAM, I wouldn't expect any difference at all, with maybe even slightly more memory consumed by HDF5 due to computations related to format processing.

CodePudding user response:

I highly doubt it is anything to do with compression.. in fact I would assume the file should be larger in hdf5 format especially in the presence of numeric features.

How did you convert from csv to hdf5? Is the number of columns and rows the same

Assuming you converting it somehow with vaex, please check if you are not looking at a single "chunk" of data. Vaex will do things in steps and then concatenate the result in a single file.

Also if some column are of unsupported type they might not be exported.

Doing some sanity checks will uncover more hints.

  • Related