2

This question is similar to this question posted before. However, I want to do something different, here is my df:

      pos  event
A     4    d5
A     2    d3
B     3    d3
B     6    u3

I want to get:

      pos  event
A     4    d5
A     2    d3
B     6    u3

I wrote this code but it is not working! any suggestion?

df.drop(df.ix[B]['event']=='d3', inplace=True)

My actual dataframe is big and I want to drop the row that I want with index and value in event column.

Scott Boston
  • 147,308
  • 15
  • 139
  • 187
NamAshena
  • 1,547
  • 5
  • 13
  • 15

1 Answers1

3

You can use boolean indexing with | (or):

print (df[(df['event']!='d3') | (df.index != 'B')])
   pos event
A    4    d5
A    2    d3
B    6    u3
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252