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

相关文章:

  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2021-07-11
  • 2022-12-23
  • 2022-02-01
  • 2021-07-24
  • 2021-07-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2021-12-04
  • 2021-11-26
  • 2022-12-23
相关资源
相似解决方案