Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Introduction to pandas Exploring pandas Optional Challenge #1 - Top Referrers

Nancy Melucci
PLUS
Nancy Melucci
Courses Plus Student 36,158 Points

Why doesn't this work? top_referrals_index = users.where(users['referral_count'] > 4 & users['email_verified'] == True)

Optional Challenge 1, I feel like I've tried everything but it keeps failing the tests. Can anyone see why the email_verified check is returning some False values?

4 Answers

Megan Amendola
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Megan Amendola
Treehouse Teacher

It looks like you're missing some parentheses (). You want to surround your expressions with parentheses to control the order of operations. The example given at the bottom of this instruction step is a good reference. I also removed the 'where' using the example as my guide. See if this works for you.

top_referrals_index = users[(users['referral_count'] >= 5) & (users['email_verified'] == True)]
Nancy Melucci
Nancy Melucci
Courses Plus Student 36,158 Points

This looks good, and it looks like one of the versions I tried by consulting various pandas resources on the inter-webs. It still fails all the tests based on not having only TRUEs and having some returns with less than 5 referral counts. However, when I view the whole data frame for top_referrals_index, the output is correct (so, the answer should work, and probably so should some of mine.)

Is it possible there is something wrong with the testing program? Thanks for responding. I hope we can figure this out. I know it's optional because I'd like to pass it.

Megan Amendola
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Megan Amendola
Treehouse Teacher

Hey, Nancy!

I tried the above in the binder notebook and it passes all tests for me. I left it as:

users[(users['referral_count'] >= 5) & (users['email_verified'] == True)]

I tried at first the recommended Kernel > Restart and Run All but that didn't change the table view at all so instead I ran each cell individually and that changed the table view and showed that I passed all tests. Try running each cell from the top-down individually and see how that goes.

Nancy Melucci
PLUS
Nancy Melucci
Courses Plus Student 36,158 Points

OK, I cleared the kernel, ran everything again, in order, and I copy/pasted your code. It still fails. Stumped.

Nancy Melucci
PLUS
Nancy Melucci
Courses Plus Student 36,158 Points

The link is asking for a password...thanks for your patient help. NJM

Nancy Melucci
PLUS
Nancy Melucci
Courses Plus Student 36,158 Points

OK, so apparently Jupyter was angry that I made a new cell and ran it...that was the actual problem

Thank you so much. I really do appreciate your patience.