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
  • 19,076
  • 4
  • 25
  • 52

2 Answers2

0

Try this

df = df[df['Category'] != 'Physics']
kspr
  • 870
  • 3
  • 18
0

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

filtered = df[df["Category"] != "Physics"]
orlp
  • 106,415
  • 33
  • 201
  • 300