ValueError: Нет набора данных в файле HDF5 с pandas.read_hdf из файла MatLab h5 - PullRequest
0 голосов
/ 02 июля 2018

Я получаю ValueError: No dataset in HDF5 file. при использовании:

In [1]: import pandas as pda

In [2]: store = pda.read_hdf('X.h5')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-72e9d80a2c5b> in <module>()
----> 1 store = pda.read_hdf('X.h5')

/usr/local/miniconda3/envs/tensorFlow-GPU/lib/python3.6/site-packages/pandas/io/pytables.py in read_hdf(path_or_buf, key, mode, **kwargs)
    356             groups = store.groups()
    357             if len(groups) == 0:
--> 358                 raise ValueError('No dataset in HDF5 file.')
    359             candidate_only_group = groups[0]
    360

ValueError: No dataset in HDF5 file.

h5dump показывает:

$ h5dump -n X.h5
HDF5 "X.h5" {
FILE_CONTENTS {
 group      /
 dataset    /DS
 }
}

И если я использую h5py, я вижу данные:

In [3]: import h5py
/usr/local/miniconda3/envs/tensorFlow-GPU/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters

In [4]: f = h5py.File('X.h5','r')

In [5]: f.keys()
Out[5]: KeysView(<HDF5 file "X.h5" (mode r)>)

In [6]: list( f.keys() )
Out[6]: ['DS']

In [7]: f['DS']
Out[7]: <HDF5 dataset "DS": shape (10, 20), type "<f8">

In [8]: f['DS'][:]
Out[8]:
array([[1., 0., 1., 1., 0., 0., 1., 1., 1., 1., 0., 1., 0., 0., 0., 1.,
        0., 1., 0., 0.],
       [0., 0., 0., 1., 0., 1., 1., 0., 1., 0., 1., 1., 1., 1., 0., 0.,
        1., 1., 0., 0.],
       [0., 1., 1., 1., 1., 0., 1., 1., 1., 0., 1., 0., 1., 1., 0., 0.,
        1., 1., 0., 0.],
       [0., 0., 1., 1., 1., 1., 1., 1., 1., 0., 0., 1., 1., 1., 1., 1.,
        1., 0., 1., 0.],
       [0., 1., 1., 1., 0., 1., 1., 1., 1., 1., 1., 0., 1., 1., 0., 1.,
        0., 1., 0., 0.],
       [0., 0., 1., 1., 1., 1., 0., 1., 1., 1., 0., 1., 1., 0., 1., 1.,
        1., 1., 0., 0.],
       [0., 0., 0., 0., 1., 1., 1., 1., 1., 1., 0., 0., 1., 1., 0., 1.,
        1., 1., 0., 1.],
       [0., 0., 1., 1., 1., 0., 1., 0., 0., 0., 0., 0., 0., 1., 0., 0.,
        0., 1., 0., 1.],
       [0., 0., 0., 1., 1., 1., 1., 1., 0., 0., 0., 0., 1., 1., 1., 0.,
        1., 0., 0., 0.],
       [0., 1., 0., 1., 1., 1., 1., 1., 1., 0., 0., 1., 1., 1., 0., 1.,
        1., 0., 0., 0.]])
...