-1

I have a DataFrame with a series that contains '@@@'. I want to delete rows containing this pattern.

I wrote the code for matching like this:

df[df['employee'].str.match('@', na = False)]

How do I delete the row if a match is found?

Jordan
  • 365
  • 1
  • 10
sre
  • 249
  • 1
  • 12

2 Answers2

1

Use pandas.DataFrame.drop:

df = df.drop(df[df['employee'].str.match('@',na=False)].index)    
snowneji
  • 1,086
  • 1
  • 11
  • 25
1

From what I understand, you want to remove the rows that are filled with @@@ in the column employee. If that is correct, then try:

df = df.loc[df["employee"] != "@@@"]
Arturo Sbr
  • 5,567
  • 4
  • 38
  • 76