サンプルセッション
In [1]: store = pd.HDFStore('test.h5')
In [2]: store['node()'] = Series(np.arange(10))
/usr/local/lib/python2.7/site-packages/tables/path.py:99: NaturalNameWarning: object name is not a valid Python identifier: 'node()'; it does not match the pattern ``^[a-zA-Z_][a-zA-Z0-9_]*$``; you will not be able to use natural naming to access this object; using ``getattr()`` will still work, though
NaturalNameWarning)
In [3]: store
Out[3]:
<class 'pandas.io.pytables.HDFStore'>
File path: test.h5
/df frame_table (typ->appendable,nrows->11,ncols->2,indexers->[index],dc->[A,B])
/node() series (shape->[10])
In [4]: store.keys()
Out[4]: ['/df', '/node()']
In [5]: store['node()/foo'] = Series(np.arange(10))
In [6]: store.keys()
Out[6]: ['/df', '/node()', '/node()/foo']
In [7]: store
Out[7]:
<class 'pandas.io.pytables.HDFStore'>
File path: test.h5
/df frame_table (typ->appendable,nrows->11,ncols->2,indexers->[index],dc->[A,B])
/node() series (shape->[10])
/node()/foo series (shape->[10])
In [8]: store['my_type\mysource\id_01_01'] = Series(np.arange(10))
/usr/local/lib/python2.7/site-packages/tables/path.py:99: NaturalNameWarning: object name is not a valid Python identifier: 'my_type\\mysource\\id_01_01'; it does not match the pattern ``^[a-zA-Z_][a-zA-Z0-9_]*$``; you will not be able to use natural naming to access this object; using ``getattr()`` will still work, though
NaturalNameWarning)
In [9]: store
Out[9]:
<class 'pandas.io.pytables.HDFStore'>
File path: test.h5
/df frame_table (typ->appendable,nrows->11,ncols->2,indexers->[index],dc->[A,B])
/my_type\mysource\id_01_01 series (shape->[10])
/node() series (shape->[10])
/node()/foo series (shape->[10])
In [10]: store.keys()
Out[10]: ['/df', '/my_type\\mysource\\id_01_01', '/node()', '/node()/foo']
In [11]: store['my_type/mysource/id_01_01'] = Series(np.arange(10))
In [12]: store
Out[12]:
<class 'pandas.io.pytables.HDFStore'>
File path: test.h5
/df frame_table (typ->appendable,nrows->11,ncols->2,indexers->[index],dc->[A,B])
/my_type\mysource\id_01_01 series (shape->[10])
/node() series (shape->[10])
/node()/foo series (shape->[10])
/my_type/mysource/id_01_01 series (shape->[10])
問題は、識別子 'my_type\mysource\id_01_01` が思ったとおりに動作せず、ファイル パスのように見えることです。スラッシュではなく、バックスラッシュが必要です (アーキテクチャに依存するため)。理論的にはこれでうまくいきます (ただし、警告を避けるために、これらの名前を変更することをお勧めします)。