gpt4 book ai didi

python - Pandas Hdf 获取表信息

转载 作者:太空宇宙 更新时间:2023-11-04 00:49:02 28 4
gpt4 key购买 nike

有没有办法使用 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com