0

I'm using df=df.drop(index='historical book') to delete all the rows that contain historical book.

the first line is the header

id           name book              subject                       amount
1            name1                  historical book               6
2            name2                  literature book               9
3            name3                  historical book               4

I get an error that it's not found in axis. Do you know why?

Thank you!

ddd
  • 3
  • 5

1 Answers1

1

Just do this:

print(df[~df['subject'].str.contains('historical book')])

   id name book          subject  amount
1   2     name2  literature book       9
NYC Coder
  • 7,424
  • 2
  • 11
  • 24