当尝试读取h5文件时,我得到以下错误:ValueError: key must be provided when HDF5 file contains multiple datasets。
f=pd.read_hdf('file_path')
ValueError Traceback (most recent call last)
384 for group_to_check in groups[1:]:
385 if not _is_metadata_of(group_to_check, candidate_only_group):
--> 386 raise ValueError('key must be provided when HDF5 file '
387 'contains multiple datasets.')
388 key = candidate_only_group._v_pathname
ValueError: key must be provided when HDF5 file contains multiple datasets.有没有人可以给我完整的代码,这样我就可以解决这个错误并在pandas中工作
发布于 2019-05-27 19:24:56
正如@AT_asks在注释中提到的,您必须提供要在H5文件中打开的组的名称。如果您不知道该文件的名称,可以查看该文件包含哪些组:
with pd.HDFStore('file_path') as hdf:
# This prints a list of all group names:
print(hdf.keys())选择一个组名,并使用read_hdf的key参数将其打开
f = pd.read_hdf('file_path', key='your_group')https://stackoverflow.com/questions/56323894
复制相似问题