Pandas 多个过滤器 str.contains 或不包含

我需要在表的 2 列结构上构建多个过滤器是 7 列,但第一个“查询”和最后一个“模板”正在过滤


我以前做过,但现在(一年后)我不知道出了什么问题。


for item in glob.glob('D:\\path\\*.change'):

    table = pd.read_csv(item, sep='\t', index_col=None)

#FILTERING

    filtered_table = table[

        (table['query'].str.contains("egg*", regex=True)==False) &

        (table['query'].str.contains(".*phospho*", regex=True)==False) &

        (table['query'].str.contains("vipe", regex=True)==False) &

        (table['template'].str.contains("ABC1")) |

        (table['template'].str.contains("bender")) ]

预期结果是没有包含字符串的行的表 - egg*, 。'query' 列中的phospho、 vipe 和包含 'ABC1' 或 'bender' 的列 'template' 中的行。


互换的青春
浏览 1167回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python