python - Pandas Hdf 获取表信息

标签 python pandas hdfstore

有没有办法使用 pandas HDF 存储获取 HDF 表的信息?

例如在 SQL 中:

SELECT COUNT(*)

我想读取基本的表格大小,而无需加载表格本身。

最佳答案

试试这个:

In [4]: %paste
store_path = r'c:/temp/.data/test.h5'
store_key = 'test'

df.to_hdf(store_path, key=store_key, mode='w', format='t', complib='zlib', complevel=4)
## -- End pasted text --

In [5]: store =  pd.HDFStore(store_path)

可用的方法

In [6]: store.
store.append                store.flush                 store.items                 store.root
store.append_to_multiple    store.get                   store.iteritems             store.select
store.close                 store.get_node              store.keys                  store.select_as_coordinates
store.copy                  store.get_storer            store.open                  store.select_as_multiple
store.create_table_index    store.groups                store.put                   store.select_column
store.filename              store.is_open               store.remove

显示项目

In [6]: store.items
Out[6]:
<bound method HDFStore.items of <class 'pandas.io.pytables.HDFStore'>
File path: c:/temp/.data/test.h5
/test            frame_table  (typ->appendable,nrows->1000000,ncols->3,indexers->[index])>

In [8]: store.append('test_indexed', df, data_columns=df.columns)

In [9]: store.items
Out[9]:
<bound method HDFStore.items of <class 'pandas.io.pytables.HDFStore'>
File path: c:/temp/.data/test.h5
/test                    frame_table  (typ->appendable,nrows->1000000,ncols->3,indexers->[index])
/test_indexed            frame_table  (typ->appendable,nrows->1000000,ncols->3,indexers->[index],dc->[A,B,C])>

Docs

关于python - Pandas Hdf 获取表信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37985786/

相关文章:

Pandas HDFStore : slow on query for non-matching string

python - 如何从 HDFStore 中的框架中选择列

python-2.7 - 如何处理在每个单元格中都有一个字典列表的 Pandas 列

python - 我如何开始使用 python 在 web Scrapy 中编写单元测试?

python - 无法识别不存在的文件

python - python循环起始月份和起始年份到结束月份和年份

Python:具有开始日期和结束日期的数据框,解压缩到 1 个日期字段

python - 确认两个 Pandas 数据帧的相等性?

python - 使 matplotlib 图形部分不可见

Python:有效地为每个组提取单个值