0

I have a column in my Data-Frame and ]t should have a "Yes" values, But my Unit-Test code has an error. Here is my code:

data = func("value") assert all("Yes" in data == True) 

The error is :

'bool' object is not iterable 
2
  • What is "an error". Please paste the full contents of the error message. Commented Dec 31, 2021 at 16:17
  • Errors is : boolean is not iterable Commented Dec 31, 2021 at 16:19

2 Answers 2

1

If you simply want to check that one "Yes" string exists in the data variable

assert "Yes" in data 

If you want to use check every element of the list is "Yes"

assert all(x == "Yes" for x in data) 

However, this is for lists, not dataframes. If you have a pandas dataframe

assert data['column'].str.contains('Yes') 
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, I added .any at end of the third solution and it worked
0

all should take iterable as an argument not boolean that's why you get this error.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.