0

I have a fairly large data frame from which I need to remove values. I currently use this code:

for sha in shas:
        df = df[~df['SHA256'].str.contains(sha, regex=False)]

However, this doesn't scale well if shas gets sufficiently large. Is there a more efficient and faster way to drop elements from a dataframe?

simplex123
  • 47
  • 2
  • 7

1 Answers1

1

You may want to use isin() method rather than looping through.

df = df[~df['SHA256'].isin(shas)]

Edit: This solution only applies with values having an exact match. If you want a solution for values containing some other value, than check this solution

null
  • 1,944
  • 1
  • 14
  • 24