0

I have dataframes in the form of:

            price       percentage
Date        
2021-10-11  298.075989  NaN
2021-10-18  308.570007  0.035206
2021-10-25  308.130005  -0.001426

I would like to check whether all the percentages (except NaN) are above 2 percent and then I would like to print a certain statement. How do I do that? Thanks in advance

2
  • Maybe something like print('All Above 2%' if df['percentage'].dropna().gt(0.02).all() else 'Not All Above 2%') Commented Oct 25, 2021 at 22:02
  • did it answer your question? If so, please accept or comment otherwise Commented Nov 24, 2021 at 8:13

1 Answer 1

1

Your example seems a bit off, but does this satisfy your needs?

if all(df.percentage.dropna() > 2):
    print('All are above 2 percent!')
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.