Drop a specific row in Pandas

df = pd.DataFrame([['Jhon',15,'A'],['Anna',19,'B'],['Paul',25,'D']])
df. columns = ['Name','Age','Grade']

df
Out[472]: 
   Name  Age Grade
0  Jhon   15     A
1  Anna   19     B
2  Paul   25     D

You can get the index of your row:

i = df[((df.Name == 'jhon') &( df.Age == 15) & (df.Grade == 'A'))].index

and then drop it:

df.drop(i)
Out[474]: 
   Name  Age Grade
1  Anna   19     B
2  Paul   25     D

As @jezrael pointed our, you can also just negate all three:

df[((df.Name != 'jhon') &( df.Age != 15) & (df.Grade != 'A'))]
Out[477]: 
   Name  Age Grade
1  Anna   19     B
2  Paul   25     D

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)