2014-03-05 40 views
1

我試圖將數據存儲爲hdf格式,並且希望將默認數據類型設置爲表格,以便日後可以查詢。熊貓不修改默認的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

這要求> = 0.13。 (它在文檔中沒有提到,情況就是如此,請謹慎爲文檔修復做一個PR)? – Jeff

回答

2

此功能在0.13推出複製。所以你需要最低熊貓版本,參見here

請注意,主要文檔沒有提及此最低版本要求。

+0

好的,謝謝你們! – Lucidnonsense