Pandas和HDF5,查询表,包含'&'字符的字符串

jan*_*gan 9 python hdf5 pandas

我遇到了与HDFStore分组的问题,结果扩展到根据包含'&'字符的字符串选择行.这应该说明问题

>>> from pandas import HDFStore, DataFrame
>>> df = DataFrame({'a': ['a', 'a', 'c', 'b', 'test & test', 'c' , 'b', 'e'], 
                   'b': [1, 2, 3, 4, 5, 6, 7, 8]})
>>> store = HDFStore('test.h5')
>>> store.append('test', df, format='table', data_columns=True)
>>> df[df.a == 'test & test']
Run Code Online (Sandbox Code Playgroud)
     a              b
4    test & test    5
>>> store.select('test', 'a="test & test"')
Run Code Online (Sandbox Code Playgroud)
Int64Index([], dtype='int64')   Empty DataFrame

现在我想知道我是否遗漏了文档中的内容或者这是一个错误.

Ali*_*ist -2

在我看来,h5py 是一个比 pandas 更强大的 HDF5 文件 Python 模块。 http://www.h5py.org/

  • 问题是关于如何使用 Pandas。这个答案与当前的问题无关。 (2认同)