gpt4 book ai didi

python - Pandas 不修改默认的 hdf 格式

转载 作者:行者123 更新时间:2023-12-01 05:21:28 28 4
gpt4 key购买 nike

我正在尝试将数据存储为 hdf 格式,并希望将默认数据类型设置为表,以便稍后查询。

我正在使用基本代码:

import pandas as pd
from numpy import random as R
pd.set_option('io.hdf.default_format','table')

s = pd.Series(R.randn(5), index=['a', 'b', 'c', 'd', 'e'])
store = pd.HDFStore('store.h5')
store['s'] = s
print store['s']

a = pd.read_hdf('store.h5','s',where="index=='a'")
print a

但是,它输出

Traceback (most recent call last):
File "C:\Users\User\Documents\Project work\GalaxyFitting\tests\pandas_test.py", line 3, in <module>
pd.set_option('io.hdf.default_format','table')
File "C:\python27\lib\site-packages\pandas\core\config.py", line 230, in __call__
return self.__func__(*args, **kwds)
File "C:\python27\lib\site-packages\pandas\core\config.py", line 143, in _set_option
_set_multiple_options(args, silent)
File "C:\python27\lib\site-packages\pandas\core\config.py", line 114, in _set_multiple_options
_set_single_option(k, v, silent)
File "C:\python27\lib\site-packages\pandas\core\config.py", line 98, in _set_single_option
key = _get_single_key(pat, silent)
File "C:\python27\lib\site-packages\pandas\core\config.py", line 76, in _get_single_key
raise KeyError('No such keys(s)')
KeyError: 'No such keys(s)'
[Finished in 0.8s]

为什么会发生这种情况?我所做的只是从the documentation复制

谢谢

最佳答案

此功能在 0.13 中引入。所以你需要最低的 pandas 版本,请参阅 here .

请注意,主要文档没有提及此最低版本要求。

关于python - Pandas 不修改默认的 hdf 格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22199589/

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