1

I come today with a rather simple problem. I have a dataframe containing values for individuals.

df = pd.DataFrame({'Names': ['John', 'Edward', 'Sean'],
                 'Age': ['21', '44', '35']})

What I am looking forward to do is to remove some lines that contain individuals from a list.

list = ['Edward', 'Martin', 'Paul']

So the desired output should be a dataframe without Edward's line.

I have tried some things but I only get a list with False and True Values :

print(df.index.isin(list))

Thank you in advance

EdChum
  • 376,765
  • 198
  • 813
  • 562
Nicolas Peille
  • 149
  • 1
  • 2
  • 10
  • Just use these booleans on your df like `df[bools]` – Tom Wojcik Feb 19 '19 at 15:14
  • basically you want `df.loc[~df['Names'].isin(list)]`, presumably you haven't really named a variable as `list` which would shadow the type `list` – EdChum Feb 19 '19 at 15:14
  • You should never use 'list' as a variable name, since it is an important keyword. Use 'mylist' etc. – rnso Feb 19 '19 at 15:15

0 Answers0