Python 检查密钥是否在HDF5Store中,且没有路径

Python 检查密钥是否在HDF5Store中,且没有路径,python,pandas,hdf5,pytables,Python,Pandas,Hdf5,Pytables,使用pandas/pytables,可以使用store.keys()轻松返回密钥列表 使用标准字典检查键是否存在,如果store.keys()中的'df_coord':,则返回false,除非包含/。是否有另一种简单的方法可以在不必连接字符串的情况下评估密钥的存在?检查存储本身;它们.keys()返回精确键的字符串字典 In [1]: store = pd.HDFStore('test.h5',mode='w') In [2]: store['foo'] = DataFrame(np.rand

使用pandas/pytables,可以使用
store.keys()
轻松返回密钥列表


使用标准字典检查键是否存在,
如果store.keys()中的'df_coord':
,则返回false,除非包含
/
。是否有另一种简单的方法可以在不必连接字符串的情况下评估密钥的存在?

检查存储本身;它们
.keys()
返回精确键的字符串字典

In [1]: store = pd.HDFStore('test.h5',mode='w')

In [2]: store['foo'] = DataFrame(np.random.randn(10,2))

In [3]: store['bar'] = DataFrame(np.random.randn(10,2))

In [4]: store
Out[4]: 
<class 'pandas.io.pytables.HDFStore'>
File path: test.h5
/bar            frame        (shape->[10,2])
/foo            frame        (shape->[10,2])

In [5]: 'bar' in store
Out[5]: True

In [6]: 'foo' in store
Out[6]: True

In [7]: '/foo' in store
Out[7]: True

In [8]: 'bah' in store
Out[8]: False
[1]中的
:store=pd.HDFStore('test.h5',mode='w')
在[2]中:存储['foo']=DataFrame(np.random.randn(10,2))
在[3]中:存储['bar']=DataFrame(np.random.randn(10,2))
在[4]:商店
出[4]:
文件路径:test.h5
/钢筋框架(形状->[10,2])
/foo框架(形状->[10,2])
在[5]中:“酒吧”在商店里
Out[5]:对
在[6]中:“foo”在商店里
Out[6]:对
在[7]中:“/foo”在商店中
Out[7]:对
在[8]中:“呸”在商店里
Out[8]:假
In [1]: store = pd.HDFStore('test.h5',mode='w')

In [2]: store['foo'] = DataFrame(np.random.randn(10,2))

In [3]: store['bar'] = DataFrame(np.random.randn(10,2))

In [4]: store
Out[4]: 
<class 'pandas.io.pytables.HDFStore'>
File path: test.h5
/bar            frame        (shape->[10,2])
/foo            frame        (shape->[10,2])

In [5]: 'bar' in store
Out[5]: True

In [6]: 'foo' in store
Out[6]: True

In [7]: '/foo' in store
Out[7]: True

In [8]: 'bah' in store
Out[8]: False