Skip to content
Advertisement

Remove rows in pandas dataframe if any of specific columns contains a specific value

I have the following df:

Data Frame

I have not been able to figure out how to delete a row if any of the columns containing the word “test” is less than 95. For example, I would have to delete the entire index row 1 because the column “heat.test” is 80 (the same for rows 0 and 3). In other words, if only one column meets this condition, the whole row must be deleted.

Thank you!

Advertisement

Answer

I think this is what you’re asking:

JavaScript

Example (df):

JavaScript

Output of the operation above:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement