我正在尝试将数据存储到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
复制由于