Pandas can't read hdf5 file created with h5py

后端 未结 1 578
悲哀的现实
悲哀的现实 2020-11-30 12:21

I get pandas error when I try to read HDF5 format files that I have created with h5py. I wonder if I am just doing something wrong?

import h5py
import numpy          


        
相关标签:
1条回答
  • 2020-11-30 12:51

    I've worked a little on the pytables module in pandas.io and from what I know pandas interaction with HDF files is limited to specific structures that pandas understands. To see what these look like, you can try

    import pandas as pd
    import numpy as np
    pd.Series(np.zeros((3,5),dtype=np.float32).to_hdf('test.h5','test')
    

    If you open 'test.h5' in HDFView, you will see a path /test with 4 items that are needed to recreate the DataFrame.

    So I think your only option for reading in NumPy arrays is to read them in directly and then convert these to Pandas objects.

    0 讨论(0)
提交回复
热议问题