{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Challenge 2 - Update Users\n", "\n", "We at CashBox would like you to update the user with email address kimberly@yahoo.com to have the last name \"Deal\".\n", "\n", "There is a misspelling of a user whose username is **jeffrey**. It should only be one `f`, **jefrey**.\n", "\n", "There are a couple ways to make this change happen, let's see what you can figure out!\n", "\n", "After you've completed the TODO's click the `Run Tests` button\n", "\n", "*Need a little extra help? Check out the [Treehouse Forum](https://teamtreehouse.com/community?instruction=4572).*" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "475" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Setup\n", "import os\n", "import pandas as pd\n", "\n", "from tests.helpers import check\n", "\n", "pd.options.display.max_rows = 10\n", "users = pd.read_csv(os.path.join('data', 'users.csv'), index_col=0)\n", "# Pop out a quick sanity check\n", "len(users)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
first_namelast_nameemailemail_verifiedsignup_datereferral_countbalance
aaronAaronDavisaaron6348@gmail.comTrue2018-08-31618.14
acookAnthonyCookcook@gmail.comTrue2018-05-12255.45
adam.saundersAdamSaundersadam@gmail.comFalse2018-05-29372.12
adrianAdrianFangadrian.fang@teamtreehouse.comTrue2018-04-28330.01
adrian.blairAdrianBlairadrian9335@gmail.comTrue2018-06-16725.85
........................
wilsonRobertWilsonrobert@yahoo.comFalse2018-05-16559.75
wkingWandaKingwanda.king@holt.comTrue2018-06-01267.08
wright3590JacquelineWrightjacqueline.wright@gonzalez.comTrue2018-02-08618.48
youngJessicaYoungjessica4028@yahoo.comTrue2018-07-17475.39
zachary.nealZacharyNealzneal@gmail.comTrue2018-07-26139.90
\n", "

475 rows × 7 columns

\n", "
" ], "text/plain": [ " first_name last_name email \\\n", "aaron Aaron Davis aaron6348@gmail.com \n", "acook Anthony Cook cook@gmail.com \n", "adam.saunders Adam Saunders adam@gmail.com \n", "adrian Adrian Fang adrian.fang@teamtreehouse.com \n", "adrian.blair Adrian Blair adrian9335@gmail.com \n", "... ... ... ... \n", "wilson Robert Wilson robert@yahoo.com \n", "wking Wanda King wanda.king@holt.com \n", "wright3590 Jacqueline Wright jacqueline.wright@gonzalez.com \n", "young Jessica Young jessica4028@yahoo.com \n", "zachary.neal Zachary Neal zneal@gmail.com \n", "\n", " email_verified signup_date referral_count balance \n", "aaron True 2018-08-31 6 18.14 \n", "acook True 2018-05-12 2 55.45 \n", "adam.saunders False 2018-05-29 3 72.12 \n", "adrian True 2018-04-28 3 30.01 \n", "adrian.blair True 2018-06-16 7 25.85 \n", "... ... ... ... ... \n", "wilson False 2018-05-16 5 59.75 \n", "wking True 2018-06-01 2 67.08 \n", "wright3590 True 2018-02-08 6 18.48 \n", "young True 2018-07-17 4 75.39 \n", "zachary.neal True 2018-07-26 1 39.90 \n", "\n", "[475 rows x 7 columns]" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "## CHALLENGE - Update users ##\n", "\n", "# TODO: Update kimberly@yahoo.com to have the last name of \"Deal\"\n", "\n", "# TODO: Update the username jeffrey to jefrey (only one f)\n", "\n", "# Return the whole data frame\n", "users" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "ca87e33565ed41e39c1d89da5125f6cc", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Button(description='Run Tests', style=ButtonStyle())" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/markdown": [ "```\n", "FF\n", "======================================================================\n", "FAIL: test_jeffrey_with_one_f (tests.helpers.TestUpdateUsers)\n", "----------------------------------------------------------------------\n", "Traceback (most recent call last):\n", " File \"/Users/craig/Code/scripting/intro-to-pandas/tests/test_cells.py\", line 56, in test_jeffrey_with_one_f\n", " 'Did you rename the username jeffrey to jefrey?'\n", "AssertionError: False is not true : Did you rename the username jeffrey to jefrey?\n", "\n", "======================================================================\n", "FAIL: test_kim_deal (tests.helpers.TestUpdateUsers)\n", "----------------------------------------------------------------------\n", "Traceback (most recent call last):\n", " File \"/Users/craig/Code/scripting/intro-to-pandas/tests/test_cells.py\", line 50, in test_kim_deal\n", " 'Are you sure you updated the last name of kimberly@yahoo.com to \"Deal\"?'\n", "AssertionError: nan != 'Deal' : Are you sure you updated the last name of kimberly@yahoo.com to \"Deal\"?\n", "\n", "----------------------------------------------------------------------\n", "Ran 2 tests in 0.003s\n", "\n", "FAILED (failures=2)\n", "\n", "```" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "check(__name__, 'Update users')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.1" } }, "nbformat": 4, "nbformat_minor": 2 }