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
  • 133,446
  • 13
  • 126
  • 161
NamAshena
  • 1,127
  • 3
  • 11
  • 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
  • 729,927
  • 78
  • 1,141
  • 1,090