We want you to produce a new DataFrame that contains the only following columns:
Ensure that all first names are title cased. Do not include any records that have a missing last name, and make sure that their email is verified (email_verified
should be set True). Sort by last name and then by first.
Choose Kernel > Restart & Run all
to run the tests properly.
# Setup
import os
import pandas as pd
from utils import make_chaos
from tests.helpers import check
pd.options.display.max_rows = 10
users = pd.read_csv(os.path.join('data', 'users.csv'), index_col=0)
# Pay no attention to the person behind the curtain
make_chaos(users, 19, ['first_name'], lambda val: val.lower())
## CHALLENGE - Verified email list ##
# TODO: Narrow list to those that have email verified.
# The only columns should be first, last and email
email_list = users[:]
# TODO: Remove any rows missing last names
# TODO: Ensure that the first names are the proper case
# Return the new sorted DataFrame..last name then first name ascending
email_list
first_name | last_name | email_verified | signup_date | referral_count | balance | ||
---|---|---|---|---|---|---|---|
aaron | Aaron | Davis | aaron6348@gmail.com | True | 2018-08-31 | 6.0 | 18.14 |
acook | Anthony | Cook | cook@gmail.com | True | 2018-05-12 | 2.0 | 55.45 |
adam.saunders | Adam | Saunders | adam@gmail.com | False | 2018-05-29 | 3.0 | 72.12 |
adrian | Adrian | Fang | adrian.fang@teamtreehouse.com | True | 2018-04-28 | 3.0 | 30.01 |
adrian.blair | Adrian | Blair | adrian9335@gmail.com | True | 2018-06-16 | 7.0 | 25.85 |
... | ... | ... | ... | ... | ... | ... | ... |
wilson | Robert | Wilson | robert@yahoo.com | False | 2018-05-16 | 5.0 | 59.75 |
wking | Wanda | King | wanda.king@holt.com | True | 2018-06-01 | 2.0 | 67.08 |
wright3590 | Jacqueline | Wright | jacqueline.wright@gonzalez.com | True | 2018-02-08 | 6.0 | 18.48 |
young | Jessica | Young | jessica4028@yahoo.com | True | 2018-07-17 | 4.0 | 75.39 |
zachary.neal | Zachary | Neal | zneal@gmail.com | True | 2018-07-26 | 1.0 | 39.90 |
475 rows × 7 columns
check(__name__, 'Verified email list')
FFFFF
======================================================================
FAIL: test_columns (tests.helpers.TestVerifiedEmailList)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/craig/Code/scripting/intro-to-pandas/tests/test_cells.py", line 92, in test_columns
', '.join(expected.columns))
AssertionError: 7 != 3 : Please only return the following columns: first_name, last_name, email
======================================================================
FAIL: test_email_verified (tests.helpers.TestVerifiedEmailList)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/craig/Code/scripting/intro-to-pandas/tests/test_cells.py", line 100, in test_email_verified
"Ensure that you are only including users with verified emails"
AssertionError: 475 != 358 : Ensure that you are only including users with verified emails
======================================================================
FAIL: test_has_na (tests.helpers.TestVerifiedEmailList)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/craig/Code/scripting/intro-to-pandas/tests/test_cells.py", line 83, in test_has_na
"Looks like there are still rows with last names missing. Drop them!"
AssertionError: 45 != 0 : Looks like there are still rows with last names missing. Drop them!
======================================================================
FAIL: test_sort (tests.helpers.TestVerifiedEmailList)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/craig/Code/scripting/intro-to-pandas/tests/test_cells.py", line 116, in test_sort
msg
AssertionError: 'Aaron' != 'Darlene'
- Aaron
+ Darlene
: Check your sort, it should be last name and then first name
======================================================================
FAIL: test_title_cased (tests.helpers.TestVerifiedEmailList)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/craig/Code/scripting/intro-to-pandas/tests/test_cells.py", line 107, in test_title_cased
"Make sure you title case the first names, there are still some lower case versions"
AssertionError: 19 != 0 : Make sure you title case the first names, there are still some lower case versions
----------------------------------------------------------------------
Ran 5 tests in 0.034s
FAILED (failures=5)