0

I have a column with 14000+ rows and there is only two numbers in this column.

for i in df['Yes/No']: if(i in "Yes"): y_counter += 1 else: n_counter += 1 

When I try this I get an equal 12/12 return for each counter. That is definitely not correct. How do I loop through and count the Yes and Nos?

1
  • 2
    df['Yes/No'].value_counts() Commented Mar 31, 2022 at 16:20

1 Answer 1

1

You can do it like this :

y_counter = (data['Yes/No'] == 'yes').sum() n_counter = (data['Yes/No'] == 'no').sum() 
Sign up to request clarification or add additional context in comments.

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.