Python 2.7 在pandas中查看hdf5文件中的行数

Python 2.7 在pandas中查看hdf5文件中的行数,python-2.7,pandas,hdf5,hdfstore,Python 2.7,Pandas,Hdf5,Hdfstore,我想知道是否有一种方法可以轻松、快速、无需加载整个文件即可获得hdf5文件中的行数,该文件是使用pandas创建的,使用pandas 提前谢谢你 [1]中的数据帧(np.random.randn(10,10)).to_hdf('test.h5','df',mode='w',format='table')) In [1]: DataFrame(np.random.randn(10,10)).to_hdf('test.h5','df',mode='w',format='table') In [3]

我想知道是否有一种方法可以轻松、快速、无需加载整个文件即可获得hdf5文件中的行数,该文件是使用pandas创建的,使用pandas

提前谢谢你

[1]中的数据帧(np.random.randn(10,10)).to_hdf('test.h5','df',mode='w',format='table'))
In [1]: DataFrame(np.random.randn(10,10)).to_hdf('test.h5','df',mode='w',format='table')

In [3]: store = pd.HDFStore('test.h5')

In [4]: store
Out[4]: 
<class 'pandas.io.pytables.HDFStore'>
File path: test.h5
/df            frame_table  (typ->appendable,nrows->10,ncols->10,indexers->[index])

In [5]: store.get_storer('df').nrows
Out[5]: 10
在[3]中:store=pd.HDFStore('test.h5')) 在[4]:商店 出[4]: 文件路径:test.h5 /df帧_表(典型->可追加,nrows->10,ncols->10,索引器->索引) 在[5]中:store.get_storer('df').nrows Out[5]:10
您是否尝试了一个简单的
pandas。在您想要的列上,先阅读_hdf()
,然后是
len()
?这种方法肯定适用于
h5py
,但我不能100%确定PyTables的读取行为。我注意到,对于固定格式的表,上面的操作给出了
None
。一个简单的解决方法是
store.get\u storer('df').shape[0]
在REPL中可视化
store
时,我没有得到
/df…
信息,但我是在执行
store.get\u storer('df')
时得到的。(我的数据帧存储为
,位于键
df