在h5文件中存储了数据框后,我试图在另一个jupyter笔记本中访问该文件但是当在pandas中以读取模式加载h5文件时遇到错误。
我以这种方式阅读文件
data_frames = pd.HDFStore('data_frames.h5', mode='r')
错误:
HDF5ExtError Traceback (most recent call last)
~/.conda/envs/be_project/lib/python3.6/site-packages/pandas/io/pytables.py in open(self, mode, **kwargs)
586 try:
--> 587 self._handle = tables.open_file(self._path, self._mode, **kwargs)
588 except (IOError) as e: # pragma: no cover
~/.conda/envs/be_project/lib/python3.6/site-packages/tables/file.py in open_file(filename, mode, title, root_uep, filters, **kwargs)
319 # Finally, create the File instance, and return it
--> 320 return File(filename, mode, title, root_uep, filters, **kwargs)
321
~/.conda/envs/be_project/lib/python3.6/site-packages/tables/file.py in __init__(self, filename, mode, title, root_uep, filters, **kwargs)
783 # Now, it is time to initialize the File extension
--> 784 self._g_new(filename, mode, **params)
785
tables/hdf5extension.pyx in tables.hdf5extension.File._g_new (tables/hdf5extension.c:5940)()
HDF5ExtError: HDF5 error back trace
File "H5F.c", line 604, in H5Fopen
unable to open file
File "H5Fint.c", line 1087, in H5F_open
unable to read superblock
File "H5Fsuper.c", line 277, in H5F_super_read
file signature not found
End of HDF5 error back trace
Unable to open/create file 'data_frames.h5'
During handling of the above exception, another exception occurred:
OSError Traceback (most recent call last)
<ipython-input-2-aa601ba65d4f> in <module>()
----> 1 data_frames = pd.HDFStore('data_frames.h5', mode='r')
~/.conda/envs/be_project/lib/python3.6/site-packages/pandas/io/pytables.py in __init__(self, path, mode, complevel, complib, fletcher32, **kwargs)
446 self._fletcher32 = fletcher32
447 self._filters = None
--> 448 self.open(mode=mode, **kwargs)
449
450 @property
~/.conda/envs/be_project/lib/python3.6/site-packages/pandas/io/pytables.py in open(self, mode, **kwargs)
617 # is not part of IOError, make it one
618 if self._mode == 'r' and 'Unable to open/create file' in str(e):
--> 619 raise IOError(str(e))
620 raise
621
OSError: HDF5 error back trace
File "H5F.c", line 604, in H5Fopen
unable to open file
File "H5Fint.c", line 1087, in H5F_open
unable to read superblock
File "H5Fsuper.c", line 277, in H5F_super_read
file signature not found
End of HDF5 error back trace
Unable to open/create file 'data_frames.h5'
请尽可能帮助。