【发布时间】:2014-03-13 05:26:18
【问题描述】:
我在使用 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']
一个
4 测试 & 测试 5
>>> store.select('test', 'a="test & test"')
Int64Index([], dtype='int64') 空数据帧
现在我想知道我是否遗漏了 documentation 中的某些内容,或者这是一个错误。
【问题讨论】:
-
错误....见这里:github.com/pydata/pandas/issues/6351;我不认为很难修复,我们有一个预解析器,它基本上可以替换某些表达式;需要让它不要在引号内这样做
-
刚刚被合并到......所以请大师试试!