0

I got a dataframe and I want to drop all the rows that contain a value >= 100 in all the columns (in the whole dataframe), not in just one specific column. I tried : df = df[(df < 100).any()] df.drop(df[(df <= 100)].index, inplace=True)

But nothing work... Could you please help ?

2
  • Do you want any row where any value is >= 100 to be dropped, or do you want any where where every value is >= 100 to be dropped? It's not 100% clear in your question. Commented Apr 25, 2022 at 23:40
  • Please provide enough code so others can better understand or reproduce the problem. Commented Apr 26, 2022 at 4:40

1 Answer 1

1

Once you have the Boolean mask (df >= 100 or df.ge(100)) you can select the rows where all values are True with all(axis=1), then reverse the resulting mask with ~ to select the desired rows from the original df.

df = df[~df.ge(100).all(axis=1)]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.