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?
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?
Use pandas.DataFrame.drop
:
df = df.drop(df[df['employee'].str.match('@',na=False)].index)
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"] != "@@@"]