3

Specifically, I want to see if my pandas dataframe contains a False.

It's an nxn dataframe, where the indices are labels.

So if all values were True except for even one cell, then I would want to return False.

1
  • 1
    Show what you have tried. Commented Jun 30, 2016 at 1:05

2 Answers 2

1

your question is a bit confusing, but assuming that you want to know whether there is at least one False in your dataframe, you could simply use

mask = df.mycol == False
mask.value_counts()
mask.sum()
mask.sum() > 0

All will tell you the truth

Sign up to request clarification or add additional context in comments.

Comments

0

If you just want to scan your whole dataframe looking for a value, check df.values. It returns an array of all the rows in the dataframe.

value = False  # This is the value you're searching
df_contains_value = any([value in row for row in df.values])

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.