1

I'm trying to store data to hdf format and want to set the default data type to table so I can query it later.

I am using the basic code:

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

However, it outputs

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]

Why is this happening? All I've done is copy from the documentation

Thanks

Community
  • 1
  • 1
Lucidnonsense
  • 1,195
  • 3
  • 13
  • 35
  • this requires >= 0.13. (It not mentioned in the docs that that is the case though, care to do a PR for that doc-fix)? – Jeff Mar 05 '14 at 13:55

1 Answers1

2

This feature was introduced in 0.13. So you need that minimum pandas version, see here.

Note that the main docs don't mention this minimum version requirement.

Jeff
  • 125,376
  • 21
  • 220
  • 187