pandas 获取不符合条件的dataframe

pandas 获取不符合条件的dataframe 或将其过滤掉:

df[df["col"].str.contains('this'|'that')==False]
>>> df = pd.DataFrame({"A": ["Hello", "this", "World", "apple"]})
>>> df[df['A'].str.contains("Hello|World")==False]
       A
1   this
3  apple

# 多个条件情况下:
# df[df["col1"].str.contains('this|that')==False and df["col2"].str.contains('foo|bar')==True]

【Reference】

1、https://blog.csdn.net/chihwei_hsu/article/details/81604455

原文地址:https://www.cnblogs.com/shenxiaolin/p/11101821.html