Delete rows with a certain condition in pandas

Question:

I have a data frame and I want to delete rows that in the column "Phrase", pattern "___" exists.

Index PHRASE Label
0 proposed by the president of the 1
1 Living ___ 1
2 "Murder, ___ Wrote" 0
But Imagin that the data fram has 2,000,000 enteries
import re

df_clean = pd.DataFrame()
z = 0
y = 0
for i in df_original["PHRASE"]:
  x = re.search("___", i)
  if x:
    y = y + 1
  else:
    df_clean.append([i])
    z = z + 1

this is what I came up with so far, I know it's not right, Does anyone know the answer? (by the way append takes a lot of time)
Asked By: Navid Aslankhani

||

Answers:

df[~df['phrase'].str.contains('___')]

Where the ~ symbol negates the operation.

Answered By: Vini
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.