We at CashBox believe that referrers are a great asset to our product. We'd like to know the top referrers with verified email addresses, so that we can send them some motivational emails.
Currently, anyone with 5 or more referrals is considered a top referrer.
When you have completed the challenge, press the Run Tests
button.
Need a little extra help? Check out the Treehouse Forum.
# Setup
import os
import pandas as pd
from tests.helpers import check
pd.options.display.max_rows = 10
users = pd.read_csv(os.path.join('data', 'users.csv'), index_col=0)
# Pop out a quick sanity check
len(users)
475
## CHALLENGE - Find the top referrers ##
# TODO: Select users that have a referral count greater than or equal to 5 and have verified emails
# Return the dataframe
users
first_name | last_name | email_verified | signup_date | referral_count | balance | ||
---|---|---|---|---|---|---|---|
aaron | Aaron | Davis | aaron6348@gmail.com | True | 2018-08-31 | 6 | 18.14 |
acook | Anthony | Cook | cook@gmail.com | True | 2018-05-12 | 2 | 55.45 |
adam.saunders | Adam | Saunders | adam@gmail.com | False | 2018-05-29 | 3 | 72.12 |
adrian | Adrian | Fang | adrian.fang@teamtreehouse.com | True | 2018-04-28 | 3 | 30.01 |
adrian.blair | Adrian | Blair | adrian9335@gmail.com | True | 2018-06-16 | 7 | 25.85 |
... | ... | ... | ... | ... | ... | ... | ... |
wilson | Robert | Wilson | robert@yahoo.com | False | 2018-05-16 | 5 | 59.75 |
wking | Wanda | King | wanda.king@holt.com | True | 2018-06-01 | 2 | 67.08 |
wright3590 | Jacqueline | Wright | jacqueline.wright@gonzalez.com | True | 2018-02-08 | 6 | 18.48 |
young | Jessica | Young | jessica4028@yahoo.com | True | 2018-07-17 | 4 | 75.39 |
zachary.neal | Zachary | Neal | zneal@gmail.com | True | 2018-07-26 | 1 | 39.90 |
475 rows × 7 columns
check(__name__, 'Find the top referrers')
Button(description='Run Tests', style=ButtonStyle())
FFF
======================================================================
FAIL: test_email_verified (tests.helpers.TestReferralCounts)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/craig/Code/scripting/intro-to-pandas/tests/test_cells.py", line 26, in test_email_verified
"I found some emails that weren't verified, are you sure you limited it by verified only?")
AssertionError: 0 != 86 : I found some emails that weren't verified, are you sure you limited it by verified only?
======================================================================
FAIL: test_referral_counts (tests.helpers.TestReferralCounts)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/craig/Code/scripting/intro-to-pandas/tests/test_cells.py", line 31, in test_referral_counts
"I found some referral counts that were less than 5. Check your condition.")
AssertionError: 0 != 300 : I found some referral counts that were less than 5. Check your condition.
======================================================================
FAIL: test_total (tests.helpers.TestReferralCounts)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/craig/Code/scripting/intro-to-pandas/tests/test_cells.py", line 35, in test_total
"Whoops I received a different count than I expected, make sure the last line "
AssertionError: 475 != 142 : Whoops I received a different count than I expected, make sure the last line is the entire resulting DataFrame (not just the head)
----------------------------------------------------------------------
Ran 3 tests in 0.006s
FAILED (failures=3)