Python/Pandas: Drop rows from data frame on string match from list

前端 未结 2 965
野的像风
野的像风 2020-12-14 10:02

I have a .csv file of contact information that I import as a pandas data frame.

>>> import pandas as pd
>>> 
>>> df = pd.read_csv         


        
2条回答
  •  悲哀的现实
    2020-12-14 10:56

    Another way using query

    In [961]: to_drop = ['Clerk', 'Bagger']
    
    In [962]: df.query('title not in @to_drop')
    Out[962]:
      fName  lName             email title
    0  John  Smith  jsmith@gmail.com   CEO
    

提交回复
热议问题