Menu Close

How to delete DataFrame row in Pandas based on column value?

To delete DataFrame row in Pandas based on column value, we put the condition of the items to return in the brackets.

For instance, we write

df = df[df.line_race != 0]

to return the df data frame values where the line_race column value isn’t 0 with

df[df.line_race != 0]
Posted in Python, Python Answers