0

I am trying to drop certain rows from a CSV file, but not by its label. I need to drop rows with certain values.

In this csv file, how would I drop every row with categroy == Physics?

img

Ch3steR
  • 20,090
  • 4
  • 28
  • 58

2 Answers2

0

Try this

df = df[df['Category'] != 'Physics']
kspr
  • 980
  • 9
  • 23
0

Assuming you read the CSV into a dataframe df, we can do:

filtered = df[df["Category"] != "Physics"]
orlp
  • 112,504
  • 36
  • 218
  • 315