我有一个HDF5格式的文件。它是使用HDF5的C ++ API创建的:
struct SignalDefH5
{
char id [128];
char name [ 64];
char units[ 16];
float min;
float max;
hvl_t tags; /* This right there does not work in Pandas... */
};
struct TagDefH5
{
char tag [ 64];
char desc[256];
};
如果我使用h5py加载文件,我会得到:
>>> import h5py
>>> hfile = h5py.File('test.h5', 'r')
>>> signals = hfile['/signals']
>>> signals[0]
('id1', 'a pressure', 'bar', 0.0, 300.0, ['Pressure'])
>>> type(signals[0][5])
numpy.ndarray
但是,如果我使用Pandas加载相同的文件,我会得到:
>>> store = pd.HDFStore('test.h5')
>>> store.root.signals
/signals (Table(179,)) ''
description := {
"id": StringCol(itemsize=128, shape=(), dflt='', pos=0),
"name": StringCol(itemsize=64, shape=(), dflt='', pos=1),
"units": StringCol(itemsize=16, shape=(), dflt='', pos=2),
"min": Float32Col(shape=(), dflt=0.0, pos=3),
"max": Float32Col(shape=(), dflt=0.0, pos=4),
"tags": StringCol(itemsize=64, shape=(), dflt='', pos=5)}
byteorder := 'little'
chunkshape := (234,)
>>> store.root.signals[0]
('id1', 'a pressure', 'bar', 0.0, 300.0, '\x02\x00\x00\x00\x00\x00\x00\x00\xf0f\x1e\x04\x00\x00\x00\x00\xba\nVT\xd1!\xa7\xdd\xb0\xe3\x9a\x02\x00\x00\x00\x00@\xecR\x1f\xa2\x7f\x00\x00}B\x178\x96\xa4u\xe6\xb0\xdd\x7f\x02\x00\x00\x00\x00 \x01')
>>> type(store.root.signals[0][5])
numpy.string_
显然Pandas方式存在问题:我做错了什么?