【发布时间】:2017-08-13 22:32:05
【问题描述】:
是否可以使用 Pytables(或 Pandas)来检测 hdf 文件的表是否包含某个列?要加载我使用的 hdf 文件:
from pandas.io.pytables import HDFStore
# this doesn't read the full file which is good
hdf_store = HDFStore('data.h5', mode='r')
# returns a "Group" object, not sure if this could be used...
hdf_store.get_node('tablename')
我也可以直接使用 Pytables 而不是 Pandas。目的不是加载 hdf 文件的所有数据,因为这些文件可能很大,我只想确定某个列是否存在。
【问题讨论】:
-
试试这个:
hdf_store['tablename'].columns -
这需要很长时间才能完成(3GB hdf 文件),所以我猜它正在拉入完整的文件。但它会返回列。