diff --git a/.DS_Store b/.DS_Store index 99ad0b6ca..99d766e79 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 448ca6eb6..5a632b6ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .ipynb_checkpoints .Rproj .Rproj.user +.python \ No newline at end of file diff --git a/01_Getting_&_Knowing_Your_Data/.DS_Store b/01_Getting_&_Knowing_Your_Data/.DS_Store new file mode 100644 index 000000000..6ac26f98a Binary files /dev/null and b/01_Getting_&_Knowing_Your_Data/.DS_Store differ diff --git a/01_Getting_&_Knowing_Your_Data/Chipotle/Exercise_with_Solutions.ipynb b/01_Getting_&_Knowing_Your_Data/Chipotle/Exercise_with_Solutions.ipynb index 32d1e7df8..162700786 100644 --- a/01_Getting_&_Knowing_Your_Data/Chipotle/Exercise_with_Solutions.ipynb +++ b/01_Getting_&_Knowing_Your_Data/Chipotle/Exercise_with_Solutions.ipynb @@ -761,7 +761,7 @@ "source": [ "# Solution 2\n", "\n", - "chipo.groupby(by=['order_id']).sum().mean()['revenue']" + "chipo.groupby('order_id')['revenue'].sum().mean()" ] }, { diff --git a/01_Getting_&_Knowing_Your_Data/World Food Facts/Exercises.ipynb b/01_Getting_&_Knowing_Your_Data/World_Food_Facts/Exercises.ipynb similarity index 100% rename from 01_Getting_&_Knowing_Your_Data/World Food Facts/Exercises.ipynb rename to 01_Getting_&_Knowing_Your_Data/World_Food_Facts/Exercises.ipynb diff --git a/01_Getting_&_Knowing_Your_Data/World Food Facts/Exercises_with_solutions.ipynb b/01_Getting_&_Knowing_Your_Data/World_Food_Facts/Exercises_with_solutions.ipynb similarity index 95% rename from 01_Getting_&_Knowing_Your_Data/World Food Facts/Exercises_with_solutions.ipynb rename to 01_Getting_&_Knowing_Your_Data/World_Food_Facts/Exercises_with_solutions.ipynb index 71299d66b..213c4e859 100644 --- a/01_Getting_&_Knowing_Your_Data/World Food Facts/Exercises_with_solutions.ipynb +++ b/01_Getting_&_Knowing_Your_Data/World_Food_Facts/Exercises_with_solutions.ipynb @@ -4,7 +4,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Ex1 - Getting and knowing your Data" + "# Ex1 - Getting and knowing your Data\n", + "Check out [World Food Facts Exercises Video Tutorial](https://youtu.be/_jCSK4cMcVw) to watch a data scientist go through the exercises" ] }, { @@ -43,9 +44,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stderr", @@ -70,9 +69,7 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -303,9 +300,7 @@ { "cell_type": "code", "execution_count": 5, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -325,9 +320,7 @@ { "cell_type": "code", "execution_count": 6, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -354,9 +347,7 @@ { "cell_type": "code", "execution_count": 7, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -391,9 +382,7 @@ { "cell_type": "code", "execution_count": 8, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -429,9 +418,7 @@ { "cell_type": "code", "execution_count": 9, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -458,9 +445,7 @@ { "cell_type": "code", "execution_count": 10, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -487,9 +472,7 @@ { "cell_type": "code", "execution_count": 11, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -516,9 +499,7 @@ { "cell_type": "code", "execution_count": 13, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -539,21 +520,34 @@ "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python [conda root]", + "display_name": "Python 3", "language": "python", - "name": "conda-root-py" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" + "pygments_lexer": "ipython3", + "version": "3.7.3" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, diff --git a/01_Getting_&_Knowing_Your_Data/World Food Facts/Solutions.ipynb b/01_Getting_&_Knowing_Your_Data/World_Food_Facts/Solutions.ipynb similarity index 100% rename from 01_Getting_&_Knowing_Your_Data/World Food Facts/Solutions.ipynb rename to 01_Getting_&_Knowing_Your_Data/World_Food_Facts/Solutions.ipynb diff --git a/02_Filtering_&_Sorting/.DS_Store b/02_Filtering_&_Sorting/.DS_Store index b086e3fb3..ca0c94aa5 100644 Binary files a/02_Filtering_&_Sorting/.DS_Store and b/02_Filtering_&_Sorting/.DS_Store differ diff --git a/02_Filtering_&_Sorting/Chipotle/Exercises.ipynb b/02_Filtering_&_Sorting/Chipotle/Exercises.ipynb index dfb68245d..33e74f649 100644 --- a/02_Filtering_&_Sorting/Chipotle/Exercises.ipynb +++ b/02_Filtering_&_Sorting/Chipotle/Exercises.ipynb @@ -70,9 +70,16 @@ "metadata": {}, "source": [ "### Step 5. What is the price of each item? \n", - "###### print a data frame with only two columns item_name and item_price" + "###### print a data frame with only three columns item_name choice_description and product_price" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, diff --git a/02_Filtering_&_Sorting/Chipotle/Exercises_with_solutions.ipynb b/02_Filtering_&_Sorting/Chipotle/Exercises_with_solutions.ipynb index ef10f6672..43f12e12f 100644 --- a/02_Filtering_&_Sorting/Chipotle/Exercises_with_solutions.ipynb +++ b/02_Filtering_&_Sorting/Chipotle/Exercises_with_solutions.ipynb @@ -4,7 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Ex1 - Filtering and Sorting Data" + "# Ex1 - Filtering and Sorting Data\n", + "\n", + "Check out [Chipotle Exercises Video Tutorial](https://youtu.be/ZZPiWZpdekA) to watch a data scientist go through the exercises" ] }, { @@ -19,7 +21,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -42,7 +44,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -60,7 +62,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -93,244 +95,237 @@ " \n", " \n", " \n", - " 4\n", - " 2\n", + " 162\n", + " 73\n", " 2\n", - " Chicken Bowl\n", - " [Tomatillo-Red Chili Salsa (Hot), [Black Beans...\n", - " 16.98\n", - " \n", - " \n", - " 5\n", - " 3\n", - " 1\n", - " Chicken Bowl\n", - " [Fresh Tomato Salsa (Mild), [Rice, Cheese, Sou...\n", - " 10.98\n", + " Canned Soda\n", + " [Diet Coke]\n", + " $2.18\n", " \n", " \n", - " 7\n", - " 4\n", + " 200\n", + " 89\n", " 1\n", - " Steak Burrito\n", - " [Tomatillo Red Chili Salsa, [Fajita Vegetables...\n", - " 11.75\n", + " Canned Soda\n", + " [Diet Coke]\n", + " $1.09\n", " \n", " \n", - " 13\n", - " 7\n", + " 317\n", + " 138\n", " 1\n", - " Chicken Bowl\n", - " [Fresh Tomato Salsa, [Fajita Vegetables, Rice,...\n", - " 11.25\n", + " Canned Soda\n", + " [Diet Coke]\n", + " $1.09\n", " \n", " \n", - " 23\n", - " 12\n", - " 1\n", - " Chicken Burrito\n", - " [[Tomatillo-Green Chili Salsa (Medium), Tomati...\n", - " 10.98\n", + " 350\n", + " 150\n", + " 2\n", + " Canned Soda\n", + " [Diet Coke]\n", + " $2.18\n", " \n", " \n", - " 39\n", - " 19\n", + " 370\n", + " 160\n", " 1\n", - " Barbacoa Bowl\n", - " [Roasted Chili Corn Salsa, [Fajita Vegetables,...\n", - " 11.75\n", + " Canned Soda\n", + " [Diet Coke]\n", + " $1.09\n", " \n", " \n", - " 42\n", - " 20\n", + " 779\n", + " 321\n", " 1\n", - " Chicken Bowl\n", - " [Roasted Chili Corn Salsa, [Rice, Black Beans,...\n", - " 11.25\n", + " Canned Soda\n", + " [Diet Coke]\n", + " $1.09\n", " \n", " \n", - " 43\n", - " 20\n", + " 1216\n", + " 496\n", " 1\n", - " Steak Burrito\n", - " [Fresh Tomato Salsa, [Rice, Pinto Beans, Chees...\n", - " 11.75\n", + " Canned Soda\n", + " [Diet Coke]\n", + " $1.09\n", " \n", " \n", - " 45\n", - " 21\n", + " 1662\n", + " 672\n", " 1\n", - " Chicken Burrito\n", - " [Tomatillo-Red Chili Salsa (Hot), [Black Beans...\n", - " 10.98\n", + " Canned Soda\n", + " [Diet Coke]\n", + " $1.09\n", " \n", " \n", - " 52\n", - " 24\n", + " 1953\n", + " 790\n", " 1\n", - " Chicken Burrito\n", - " [Roasted Chili Corn Salsa (Medium), [Black Bea...\n", - " 10.98\n", + " Canned Soda\n", + " [Diet Coke]\n", + " $1.09\n", " \n", " \n", - " 57\n", - " 26\n", - " 1\n", - " Veggie Burrito\n", - " [Tomatillo Red Chili Salsa, [Fajita Vegetables...\n", - " 11.25\n", + " 2135\n", + " 859\n", + " 2\n", + " Canned Soda\n", + " [Diet Coke]\n", + " $2.18\n", " \n", " \n", - " 58\n", - " 27\n", + " 2544\n", + " 1009\n", " 1\n", - " Barbacoa Bowl\n", - " [Roasted Chili Corn Salsa, [Fajita Vegetables,...\n", - " 11.75\n", + " Canned Soda\n", + " [Diet Coke]\n", + " $1.09\n", " \n", " \n", - " 62\n", - " 28\n", + " 2850\n", + " 1132\n", " 1\n", - " Veggie Bowl\n", - " [Fresh Tomato Salsa, [Fajita Vegetables, Rice,...\n", - " 11.25\n", + " Canned Soda\n", + " [Diet Coke]\n", + " $1.09\n", " \n", " \n", - " 68\n", - " 30\n", - " 1\n", - " Chicken Burrito\n", - " [Tomatillo-Red Chili Salsa (Hot), [Black Beans...\n", - " 10.98\n", + " 3592\n", + " 1440\n", + " 2\n", + " Canned Soda\n", + " [Diet Coke]\n", + " $2.18\n", " \n", " \n", - " 79\n", - " 35\n", + " 3793\n", + " 1518\n", " 1\n", - " Chicken Soft Tacos\n", - " [Roasted Chili Corn Salsa, [Rice, Cheese, Lett...\n", - " 11.25\n", + " Canned Soda\n", + " [Diet Coke]\n", + " $1.09\n", " \n", " \n", - " 90\n", - " 40\n", + " 4008\n", + " 1604\n", " 1\n", - " Steak Bowl\n", - " [Fresh Tomato Salsa, [Rice, Black Beans, Chees...\n", - " 11.75\n", + " Canned Soda\n", + " [Diet Coke]\n", + " $1.09\n", " \n", - " \n", - " 91\n", - " 40\n", - " 1\n", - " Steak Bowl\n", - " [Fresh Tomato Salsa, [Fajita Vegetables, Chees...\n", - " 11.75\n", + " \n", + "\n", + "" + ], + "text/plain": [ + " order_id quantity item_name choice_description item_price\n", + "162 73 2 Canned Soda [Diet Coke] $2.18 \n", + "200 89 1 Canned Soda [Diet Coke] $1.09 \n", + "317 138 1 Canned Soda [Diet Coke] $1.09 \n", + "350 150 2 Canned Soda [Diet Coke] $2.18 \n", + "370 160 1 Canned Soda [Diet Coke] $1.09 \n", + "779 321 1 Canned Soda [Diet Coke] $1.09 \n", + "1216 496 1 Canned Soda [Diet Coke] $1.09 \n", + "1662 672 1 Canned Soda [Diet Coke] $1.09 \n", + "1953 790 1 Canned Soda [Diet Coke] $1.09 \n", + "2135 859 2 Canned Soda [Diet Coke] $2.18 \n", + "2544 1009 1 Canned Soda [Diet Coke] $1.09 \n", + "2850 1132 1 Canned Soda [Diet Coke] $1.09 \n", + "3592 1440 2 Canned Soda [Diet Coke] $2.18 \n", + "3793 1518 1 Canned Soda [Diet Coke] $1.09 \n", + "4008 1604 1 Canned Soda [Diet Coke] $1.09 " + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# the item price column is actullay the price of the product multiplied by the quantity\n", + "chipo.loc[(chipo[\"choice_description\"] == '[Diet Coke]') & (chipo[\"item_name\"] == \"Canned Soda\")]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "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", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -339,428 +334,135 @@ " \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", - " \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", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", + " \n", " \n", " \n", "
order_idquantityitem_namechoice_descriptionitem_priceproduct_price
934101Carnitas Burrito[Roasted Chili Corn Salsa, [Sour Cream, Guacam...11.75
97431Carnitas Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...11.75Chips and Fresh Tomato SalsaNaN2.392.39
1235411Chicken Bowl[Fresh Tomato Salsa, [Guacamole, Cheese, Sour ...11.25
130571Barbacoa Burrito[Roasted Chili Corn Salsa, [Rice, Pinto Beans,...11.75Izze[Clementine]3.393.39
1345921Chicken Burrito[Roasted Chili Corn Salsa (Medium), [Rice, Bla...10.98
135602Chicken Salad Bowl[Tomatillo Green Chili Salsa, [Sour Cream, Che...22.50
136611Barbacoa Bowl[Tomatillo Red Chili Salsa, [Fajita Vegetables...11.75Nantucket Nectar[Apple]3.393.39
1386231Chicken Bowl[Fresh Tomato Salsa, [Rice, Fajita Vegetables,...11.25
140631Chicken Bowl[Tomatillo Green Chili Salsa, [Rice, Sour Crea...11.25Chips and Tomatillo-Green Chili SalsaNaN2.392.39
142641422Chicken Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...11.25
143641Veggie Bowl[Tomatillo Red Chili Salsa, [Fajita Vegetables...11.25
144651Barbacoa Burrito[Tomatillo Red Chili Salsa, [Rice, Sour Cream,...11.75
147661Steak Burrito[Tomatillo-Green Chili Salsa (Medium), [Rice, ...11.48[Tomatillo-Red Chili Salsa (Hot), [Black Beans...16.988.49
...............
45041791461718331Carnitas Bowl[Fresh Tomato Salsa, [Rice, Sour Cream, Guacam...Steak Burrito[Fresh Tomato Salsa, [Rice, Black Beans, Sour ...11.75
450617921Chicken Bowl[Fresh Tomato Salsa, [Rice, Cheese, Sour Cream...11.25
451017931Barbacoa Bowl[Guacamole]11.49
451817961Steak Bowl[Tomatillo Red Chili Salsa, [Rice, Black Beans...11.75
452117981Chicken Burrito[Roasted Chili Corn Salsa, [Guacamole, Lettuce...11.25
45231798461818331Steak Crispy Tacos[Tomatillo Green Chili Salsa, [Cheese, Sour Cr...Steak Burrito[Fresh Tomato Salsa, [Rice, Sour Cream, Cheese...11.75
453318021Chicken Burrito[Tomatillo Red Chili Salsa, [Fajita Vegetables...11.25
454018051Chicken Bowl[Tomatillo Green Chili Salsa, [Fajita Vegetabl...11.25
455318101Chicken Bowl[Roasted Chili Corn Salsa, [Black Beans, Sour ...11.25
455418101Steak Crispy Tacos[Roasted Chili Corn Salsa, [Fajita Vegetables,...11.75
455618111Chicken Burrito[Tomatillo Green Chili Salsa, [Fajita Vegetabl...11.25
45591812461918341Chicken Burrito[Tomatillo Red Chili Salsa, [Rice, Cheese, Gua...11.25
456118132Chicken Salad Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Pinto...17.50
456418151Chicken Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...11.25
457618201Chicken Bowl[Fresh Tomato Salsa, [Rice, Cheese, Sour Cream...11.25
45801822462018341Chicken Salad Bowl[Fresh Tomato Salsa, [Black Beans, Cheese, Gua...11.25[Fresh Tomato Salsa, [Fajita Vegetables, Lettu...8.758.75
458618241Chicken Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Chees...11.25
458718241Chicken Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Chees...11.25
458918251Chicken Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Sour ...11.25
459018251Chicken Bowl[Roasted Chili Corn Salsa, [Rice, Black Beans,...11.25
459218251Barbacoa Burrito[Tomatillo Red Chili Salsa, [Rice, Fajita Vege...11.75
459318251Carnitas Bowl[Roasted Chili Corn Salsa, [Rice, Sour Cream, ...11.75
459418251Barbacoa Bowl[Roasted Chili Corn Salsa, [Pinto Beans, Sour ...11.75
460718291Steak Burrito[Tomatillo Green Chili Salsa, [Rice, Cheese, S...11.75
460818291Veggie Burrito[Tomatillo Red Chili Salsa, [Fajita Vegetables...11.25
461018301Steak Burrito[Fresh Tomato Salsa, [Rice, Sour Cream, Cheese...11.75
461118301Veggie Burrito[Tomatillo Green Chili Salsa, [Rice, Fajita Ve...11.25
461718331Steak Burrito[Fresh Tomato Salsa, [Rice, Black Beans, Sour ...11.75
461818331Steak Burrito[Fresh Tomato Salsa, [Rice, Sour Cream, Cheese...11.75
46191834462118341Chicken Salad Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Pinto...11.258.758.75
\n", - "

1130 rows × 5 columns

\n", + "

4622 rows × 6 columns

\n", "
" ], "text/plain": [ - " order_id quantity item_name \\\n", - "4 2 2 Chicken Bowl \n", - "5 3 1 Chicken Bowl \n", - "7 4 1 Steak Burrito \n", - "13 7 1 Chicken Bowl \n", - "23 12 1 Chicken Burrito \n", - "39 19 1 Barbacoa Bowl \n", - "42 20 1 Chicken Bowl \n", - "43 20 1 Steak Burrito \n", - "45 21 1 Chicken Burrito \n", - "52 24 1 Chicken Burrito \n", - "57 26 1 Veggie Burrito \n", - "58 27 1 Barbacoa Bowl \n", - "62 28 1 Veggie Bowl \n", - "68 30 1 Chicken Burrito \n", - "79 35 1 Chicken Soft Tacos \n", - "90 40 1 Steak Bowl \n", - "91 40 1 Steak Bowl \n", - "93 41 1 Carnitas Burrito \n", - "97 43 1 Carnitas Bowl \n", - "123 54 1 Chicken Bowl \n", - "130 57 1 Barbacoa Burrito \n", - "134 59 1 Chicken Burrito \n", - "135 60 2 Chicken Salad Bowl \n", - "136 61 1 Barbacoa Bowl \n", - "138 62 1 Chicken Bowl \n", - "140 63 1 Chicken Bowl \n", - "142 64 1 Chicken Bowl \n", - "143 64 1 Veggie Bowl \n", - "144 65 1 Barbacoa Burrito \n", - "147 66 1 Steak Burrito \n", - "... ... ... ... \n", - "4504 1791 1 Carnitas Bowl \n", - "4506 1792 1 Chicken Bowl \n", - "4510 1793 1 Barbacoa Bowl \n", - "4518 1796 1 Steak Bowl \n", - "4521 1798 1 Chicken Burrito \n", - "4523 1798 1 Steak Crispy Tacos \n", - "4533 1802 1 Chicken Burrito \n", - "4540 1805 1 Chicken Bowl \n", - "4553 1810 1 Chicken Bowl \n", - "4554 1810 1 Steak Crispy Tacos \n", - "4556 1811 1 Chicken Burrito \n", - "4559 1812 1 Chicken Burrito \n", - "4561 1813 2 Chicken Salad Bowl \n", - "4564 1815 1 Chicken Bowl \n", - "4576 1820 1 Chicken Bowl \n", - "4580 1822 1 Chicken Salad Bowl \n", - "4586 1824 1 Chicken Bowl \n", - "4587 1824 1 Chicken Bowl \n", - "4589 1825 1 Chicken Bowl \n", - "4590 1825 1 Chicken Bowl \n", - "4592 1825 1 Barbacoa Burrito \n", - "4593 1825 1 Carnitas Bowl \n", - "4594 1825 1 Barbacoa Bowl \n", - "4607 1829 1 Steak Burrito \n", - "4608 1829 1 Veggie Burrito \n", - "4610 1830 1 Steak Burrito \n", - "4611 1830 1 Veggie Burrito \n", - "4617 1833 1 Steak Burrito \n", - "4618 1833 1 Steak Burrito \n", - "4619 1834 1 Chicken Salad Bowl \n", + " order_id quantity item_name \\\n", + "0 1 1 Chips and Fresh Tomato Salsa \n", + "1 1 1 Izze \n", + "2 1 1 Nantucket Nectar \n", + "3 1 1 Chips and Tomatillo-Green Chili Salsa \n", + "4 2 2 Chicken Bowl \n", + "... ... ... ... \n", + "4617 1833 1 Steak Burrito \n", + "4618 1833 1 Steak Burrito \n", + "4619 1834 1 Chicken Salad Bowl \n", + "4620 1834 1 Chicken Salad Bowl \n", + "4621 1834 1 Chicken Salad Bowl \n", "\n", - " choice_description item_price \n", - "4 [Tomatillo-Red Chili Salsa (Hot), [Black Beans... 16.98 \n", - "5 [Fresh Tomato Salsa (Mild), [Rice, Cheese, Sou... 10.98 \n", - "7 [Tomatillo Red Chili Salsa, [Fajita Vegetables... 11.75 \n", - "13 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 11.25 \n", - "23 [[Tomatillo-Green Chili Salsa (Medium), Tomati... 10.98 \n", - "39 [Roasted Chili Corn Salsa, [Fajita Vegetables,... 11.75 \n", - "42 [Roasted Chili Corn Salsa, [Rice, Black Beans,... 11.25 \n", - "43 [Fresh Tomato Salsa, [Rice, Pinto Beans, Chees... 11.75 \n", - "45 [Tomatillo-Red Chili Salsa (Hot), [Black Beans... 10.98 \n", - "52 [Roasted Chili Corn Salsa (Medium), [Black Bea... 10.98 \n", - "57 [Tomatillo Red Chili Salsa, [Fajita Vegetables... 11.25 \n", - "58 [Roasted Chili Corn Salsa, [Fajita Vegetables,... 11.75 \n", - "62 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 11.25 \n", - "68 [Tomatillo-Red Chili Salsa (Hot), [Black Beans... 10.98 \n", - "79 [Roasted Chili Corn Salsa, [Rice, Cheese, Lett... 11.25 \n", - "90 [Fresh Tomato Salsa, [Rice, Black Beans, Chees... 11.75 \n", - "91 [Fresh Tomato Salsa, [Fajita Vegetables, Chees... 11.75 \n", - "93 [Roasted Chili Corn Salsa, [Sour Cream, Guacam... 11.75 \n", - "97 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 11.75 \n", - "123 [Fresh Tomato Salsa, [Guacamole, Cheese, Sour ... 11.25 \n", - "130 [Roasted Chili Corn Salsa, [Rice, Pinto Beans,... 11.75 \n", - "134 [Roasted Chili Corn Salsa (Medium), [Rice, Bla... 10.98 \n", - "135 [Tomatillo Green Chili Salsa, [Sour Cream, Che... 22.50 \n", - "136 [Tomatillo Red Chili Salsa, [Fajita Vegetables... 11.75 \n", - "138 [Fresh Tomato Salsa, [Rice, Fajita Vegetables,... 11.25 \n", - "140 [Tomatillo Green Chili Salsa, [Rice, Sour Crea... 11.25 \n", - "142 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 11.25 \n", - "143 [Tomatillo Red Chili Salsa, [Fajita Vegetables... 11.25 \n", - "144 [Tomatillo Red Chili Salsa, [Rice, Sour Cream,... 11.75 \n", - "147 [Tomatillo-Green Chili Salsa (Medium), [Rice, ... 11.48 \n", - "... ... ... \n", - "4504 [Fresh Tomato Salsa, [Rice, Sour Cream, Guacam... 11.75 \n", - "4506 [Fresh Tomato Salsa, [Rice, Cheese, Sour Cream... 11.25 \n", - "4510 [Guacamole] 11.49 \n", - "4518 [Tomatillo Red Chili Salsa, [Rice, Black Beans... 11.75 \n", - "4521 [Roasted Chili Corn Salsa, [Guacamole, Lettuce... 11.25 \n", - "4523 [Tomatillo Green Chili Salsa, [Cheese, Sour Cr... 11.75 \n", - "4533 [Tomatillo Red Chili Salsa, [Fajita Vegetables... 11.25 \n", - "4540 [Tomatillo Green Chili Salsa, [Fajita Vegetabl... 11.25 \n", - "4553 [Roasted Chili Corn Salsa, [Black Beans, Sour ... 11.25 \n", - "4554 [Roasted Chili Corn Salsa, [Fajita Vegetables,... 11.75 \n", - "4556 [Tomatillo Green Chili Salsa, [Fajita Vegetabl... 11.25 \n", - "4559 [Tomatillo Red Chili Salsa, [Rice, Cheese, Gua... 11.25 \n", - "4561 [Fresh Tomato Salsa, [Fajita Vegetables, Pinto... 17.50 \n", - "4564 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 11.25 \n", - "4576 [Fresh Tomato Salsa, [Rice, Cheese, Sour Cream... 11.25 \n", - "4580 [Fresh Tomato Salsa, [Black Beans, Cheese, Gua... 11.25 \n", - "4586 [Fresh Tomato Salsa, [Rice, Black Beans, Chees... 11.25 \n", - "4587 [Fresh Tomato Salsa, [Rice, Black Beans, Chees... 11.25 \n", - "4589 [Fresh Tomato Salsa, [Rice, Black Beans, Sour ... 11.25 \n", - "4590 [Roasted Chili Corn Salsa, [Rice, Black Beans,... 11.25 \n", - "4592 [Tomatillo Red Chili Salsa, [Rice, Fajita Vege... 11.75 \n", - "4593 [Roasted Chili Corn Salsa, [Rice, Sour Cream, ... 11.75 \n", - "4594 [Roasted Chili Corn Salsa, [Pinto Beans, Sour ... 11.75 \n", - "4607 [Tomatillo Green Chili Salsa, [Rice, Cheese, S... 11.75 \n", - "4608 [Tomatillo Red Chili Salsa, [Fajita Vegetables... 11.25 \n", - "4610 [Fresh Tomato Salsa, [Rice, Sour Cream, Cheese... 11.75 \n", - "4611 [Tomatillo Green Chili Salsa, [Rice, Fajita Ve... 11.25 \n", - "4617 [Fresh Tomato Salsa, [Rice, Black Beans, Sour ... 11.75 \n", - "4618 [Fresh Tomato Salsa, [Rice, Sour Cream, Cheese... 11.75 \n", - "4619 [Fresh Tomato Salsa, [Fajita Vegetables, Pinto... 11.25 \n", + " choice_description item_price \\\n", + "0 NaN 2.39 \n", + "1 [Clementine] 3.39 \n", + "2 [Apple] 3.39 \n", + "3 NaN 2.39 \n", + "4 [Tomatillo-Red Chili Salsa (Hot), [Black Beans... 16.98 \n", + "... ... ... \n", + "4617 [Fresh Tomato Salsa, [Rice, Black Beans, Sour ... 11.75 \n", + "4618 [Fresh Tomato Salsa, [Rice, Sour Cream, Cheese... 11.75 \n", + "4619 [Fresh Tomato Salsa, [Fajita Vegetables, Pinto... 11.25 \n", + "4620 [Fresh Tomato Salsa, [Fajita Vegetables, Lettu... 8.75 \n", + "4621 [Fresh Tomato Salsa, [Fajita Vegetables, Pinto... 8.75 \n", + "\n", + " product_price \n", + "0 2.39 \n", + "1 3.39 \n", + "2 3.39 \n", + "3 2.39 \n", + "4 8.49 \n", + "... ... \n", + "4617 11.75 \n", + "4618 11.75 \n", + "4619 11.25 \n", + "4620 8.75 \n", + "4621 8.75 \n", "\n", - "[1130 rows x 5 columns]" + "[4622 rows x 6 columns]" ] }, - "execution_count": 21, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "# clean the item_price column and transform it in a float\n", - "prices = [float(value[1 : -1]) for value in chipo.item_price]\n", - "\n", - "# reassign the column with the cleaned prices\n", - "chipo.item_price = prices\n", - "\n", - "# delete the duplicates in item_name and quantity\n", - "chipo_filtered = chipo.drop_duplicates(['item_name','quantity','choice_description'])\n", - "\n", - "# chipo_filtered\n", - "\n", - "# select only the products with quantity equals to 1\n", - "chipo_one_prod = chipo_filtered[chipo_filtered.quantity == 1]\n", - "chipo_one_prod\n", - "\n", - "# chipo_one_prod[chipo_one_prod['item_price']>10].item_name.nunique()\n", - "# chipo_one_prod[chipo_one_prod['item_price']>10]\n", - "\n", - "\n", - "\n", - "chipo.query('price_per_item > 10').item_name.nunique()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Step 5. What is the price of each item? \n", - "###### print a data frame with only two columns item_name and item_price" + "# adding a new column representing the price of each single product in float\n", + "chipo[\"item_price\"] = chipo[\"item_price\"].str.replace(\"$\", \"\", regex=False).astype(float)\n", + "chipo[\"product_price\"] = chipo[\"item_price\"] / chipo[\"quantity\"]\n", + "chipo" ] }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "\n", " \n", " \n", @@ -768,652 +470,382 @@ " \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", - " \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", - " \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", + " \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", + "
order_idquantityitem_namechoice_descriptionitem_price
531Chicken Bowl[Fresh Tomato Salsa (Mild), [Rice, Cheese, Sou...10.98
1371Chicken Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...11.25
19101Chicken Bowl[Tomatillo Red Chili Salsa, [Fajita Vegetables...8.75
26131Chicken Bowl[Roasted Chili Corn Salsa (Medium), [Pinto Bea...8.49
42201Chicken Bowl[Roasted Chili Corn Salsa, [Rice, Black Beans,...11.25
76341Chicken Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Pinto...8.75
78341Chicken Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Chees...8.75
99441Chicken Bowl[Tomatillo Red Chili Salsa, [Rice, Fajita Vege...8.75
110491Chicken Bowl[Tomatillo Red Chili Salsa, [Rice, Black Beans...8.75
123541Chicken Bowl[Fresh Tomato Salsa, [Guacamole, Cheese, Sour ...11.25
138621Chicken Bowl[Fresh Tomato Salsa, [Rice, Fajita Vegetables,...11.25
140631Chicken Bowl[Tomatillo Green Chili Salsa, [Rice, Sour Crea...11.25
142641Chicken Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...11.25
160731Chicken Bowl[Fresh Tomato Salsa (Mild), [Black Beans, Rice...8.49
176791Chicken Bowl[Roasted Chili Corn Salsa (Medium), [Black Bea...10.98
182821Chicken Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Sour ...8.75
193861Chicken Bowl[Fresh Tomato Salsa, [Rice, Cheese, Sour Cream]]8.75
199891Chicken Bowl[[Roasted Chili Corn Salsa (Medium), Tomatillo...10.98
206921Chicken Bowl[Fresh Tomato Salsa, [Rice, Cheese, Lettuce]]8.75
209931Chicken Bowl[Roasted Chili Corn Salsa, [Fajita Vegetables,...11.25
211931Chicken Bowl[Roasted Chili Corn Salsa, [Fajita Vegetables,...11.25
218961Chicken Bowl[Tomatillo Green Chili Salsa, [Rice, Black Bea...8.75
220971Chicken Bowl[Roasted Chili Corn Salsa, [Rice, Black Beans,...8.75
224981Chicken Bowl[Tomatillo Green Chili Salsa, [Rice, Pinto Bea...8.75
2311021Chicken Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...8.75
2521101Chicken Bowl[Tomatillo Red Chili Salsa, [Rice, Cheese, Let...8.75
2571111Chicken Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Cheese]]8.75
2841241Chicken Bowl[Fresh Tomato Salsa, [Rice, Cheese, Sour Cream]]8.75
2901261Chicken Bowl[Roasted Chili Corn Salsa, [Fajita Vegetables,...11.25
2911271Chicken Bowl[Tomatillo Green Chili Salsa, [Rice, Sour Crea...11.25
..................
444317711Chicken Bowl[Tomatillo Green Chili Salsa, [Rice, Pinto Bea...8.75choice_descriptionitem_priceproduct_price
444417711Chicken Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Sour ...8.75162732Canned Soda[Diet Coke]2.181.09
44651779200891Chicken Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Cheese]]8.75Canned Soda[Diet Coke]1.091.09
448117863171381Chicken Bowl[Fresh Tomato Salsa, Rice]8.75Canned Soda[Diet Coke]1.091.09
448317861Chicken Bowl[Fresh Tomato Salsa, [Rice, Pinto Beans, Chees...11.253501502Canned Soda[Diet Coke]2.181.09
448417863701601Chicken Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...11.25Canned Soda[Diet Coke]1.091.09
448617867793211Chicken Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Chees...11.25Canned Soda[Diet Coke]1.091.09
4488178612164961Chicken Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...8.75Canned Soda[Diet Coke]1.091.09
4495178816626721Chicken Bowl[Fresh Tomato Salsa, [Rice, Pinto Beans, Sour ...11.25Canned Soda[Diet Coke]1.091.09
4498178919537901Chicken Bowl[Tomatillo Green Chili Salsa, [Fajita Vegetabl...11.25Canned Soda[Diet Coke]1.091.09
450617921Chicken Bowl[Fresh Tomato Salsa, [Rice, Cheese, Sour Cream...11.2521358592Canned Soda[Diet Coke]2.181.09
45111794254410091Chicken Bowl[Roasted Chili Corn Salsa, [Rice, Fajita Veget...8.75Canned Soda[Diet Coke]1.091.09
45321802285011321Chicken Bowl[Roasted Chili Corn Salsa, [Rice, Black Beans,...8.75Canned Soda[Diet Coke]1.091.09
453718041Chicken Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Chees...8.75359214402Canned Soda[Diet Coke]2.181.09
45401805379315181Chicken Bowl[Tomatillo Green Chili Salsa, [Fajita Vegetabl...11.25Canned Soda[Diet Coke]1.091.09
45531810400816041Chicken Bowl[Roasted Chili Corn Salsa, [Black Beans, Sour ...11.25Canned Soda[Diet Coke]1.091.09
455518111Chicken Bowl[Roasted Chili Corn Salsa, [Fajita Vegetables,...8.75
\n", + "
" + ], + "text/plain": [ + " order_id quantity item_name choice_description item_price \\\n", + "162 73 2 Canned Soda [Diet Coke] 2.18 \n", + "200 89 1 Canned Soda [Diet Coke] 1.09 \n", + "317 138 1 Canned Soda [Diet Coke] 1.09 \n", + "350 150 2 Canned Soda [Diet Coke] 2.18 \n", + "370 160 1 Canned Soda [Diet Coke] 1.09 \n", + "779 321 1 Canned Soda [Diet Coke] 1.09 \n", + "1216 496 1 Canned Soda [Diet Coke] 1.09 \n", + "1662 672 1 Canned Soda [Diet Coke] 1.09 \n", + "1953 790 1 Canned Soda [Diet Coke] 1.09 \n", + "2135 859 2 Canned Soda [Diet Coke] 2.18 \n", + "2544 1009 1 Canned Soda [Diet Coke] 1.09 \n", + "2850 1132 1 Canned Soda [Diet Coke] 1.09 \n", + "3592 1440 2 Canned Soda [Diet Coke] 2.18 \n", + "3793 1518 1 Canned Soda [Diet Coke] 1.09 \n", + "4008 1604 1 Canned Soda [Diet Coke] 1.09 \n", + "\n", + " product_price \n", + "162 1.09 \n", + "200 1.09 \n", + "317 1.09 \n", + "350 1.09 \n", + "370 1.09 \n", + "779 1.09 \n", + "1216 1.09 \n", + "1662 1.09 \n", + "1953 1.09 \n", + "2135 1.09 \n", + "2544 1.09 \n", + "2850 1.09 \n", + "3592 1.09 \n", + "3793 1.09 \n", + "4008 1.09 " + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#checking everything is correct\n", + "chipo.loc[(chipo[\"choice_description\"] == '[Diet Coke]') & (chipo[\"item_name\"] == \"Canned Soda\")]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# removing duplicated products\n", + "filtered_chipo=chipo.drop_duplicates(['item_name','choice_description'])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# filtering products that costs more than $10\n", + "filtered_chipo = filtered_chipo.loc[ filtered_chipo[\"product_price\"]>10.0 , [\"item_name\",\"choice_description\",\"product_price\"] ].reset_index(drop=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the number of products that cost more than $10.00 is 707\n" + ] + } + ], + "source": [ + "print(f\"the number of products that cost more than $10.00 is {filtered_chipo.shape[0]}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 5. What is the price of each item? \n", + "###### print a data frame with only three columns item_name choice_description and product_price" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "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", - " \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", "
item_namechoice_descriptionproduct_price
4564181510Chicken Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...11.25[Fresh Tomato Salsa (Mild), [Rice, Cheese, Sou...10.98
457418191Chicken Bowl[Roasted Chili Corn Salsa, [Rice, Cheese, Lett...8.751Steak Burrito[Tomatillo Red Chili Salsa, [Fajita Vegetables...11.75
4576182012Chicken Bowl[Fresh Tomato Salsa, [Rice, Cheese, Sour Cream...[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...11.25
458118221Chicken Bowl[Tomatillo Red Chili Salsa, [Rice, Black Beans...8.75
458318231Chicken Bowl[Tomatillo Green Chili Salsa, [Rice, Black Bea...8.75
458618241Chicken Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Chees...11.253Chicken Burrito[[Tomatillo-Green Chili Salsa (Medium), Tomati...10.98
458718241Chicken Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Chees...11.254Barbacoa Bowl[Roasted Chili Corn Salsa, [Fajita Vegetables,...11.75
458918251Chicken Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Sour ...11.25............
459018251Chicken Bowl[Roasted Chili Corn Salsa, [Rice, Black Beans,...11.25702Carnitas Bowl[Roasted Chili Corn Salsa, [Rice, Sour Cream, ...11.75
459118251Chicken Bowl[Tomatillo Red Chili Salsa, [Rice, Black Beans...8.75703Barbacoa Bowl[Roasted Chili Corn Salsa, [Pinto Beans, Sour ...11.75
459518261Chicken Bowl[Tomatillo Green Chili Salsa, [Rice, Black Bea...8.75704Steak Burrito[Tomatillo Green Chili Salsa, [Rice, Cheese, S...11.75
459918271Chicken Bowl[Roasted Chili Corn Salsa, [Cheese, Lettuce]]8.75705Steak Burrito[Fresh Tomato Salsa, [Rice, Sour Cream, Cheese...11.75
460418281Chicken Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Chees...8.75706Veggie Burrito[Tomatillo Green Chili Salsa, [Rice, Fajita Ve...11.25
\n", - "

693 rows × 5 columns

\n", + "

707 rows × 3 columns

\n", "
" ], "text/plain": [ - " order_id quantity item_name \\\n", - "5 3 1 Chicken Bowl \n", - "13 7 1 Chicken Bowl \n", - "19 10 1 Chicken Bowl \n", - "26 13 1 Chicken Bowl \n", - "42 20 1 Chicken Bowl \n", - "76 34 1 Chicken Bowl \n", - "78 34 1 Chicken Bowl \n", - "99 44 1 Chicken Bowl \n", - "110 49 1 Chicken Bowl \n", - "123 54 1 Chicken Bowl \n", - "138 62 1 Chicken Bowl \n", - "140 63 1 Chicken Bowl \n", - "142 64 1 Chicken Bowl \n", - "160 73 1 Chicken Bowl \n", - "176 79 1 Chicken Bowl \n", - "182 82 1 Chicken Bowl \n", - "193 86 1 Chicken Bowl \n", - "199 89 1 Chicken Bowl \n", - "206 92 1 Chicken Bowl \n", - "209 93 1 Chicken Bowl \n", - "211 93 1 Chicken Bowl \n", - "218 96 1 Chicken Bowl \n", - "220 97 1 Chicken Bowl \n", - "224 98 1 Chicken Bowl \n", - "231 102 1 Chicken Bowl \n", - "252 110 1 Chicken Bowl \n", - "257 111 1 Chicken Bowl \n", - "284 124 1 Chicken Bowl \n", - "290 126 1 Chicken Bowl \n", - "291 127 1 Chicken Bowl \n", - "... ... ... ... \n", - "4443 1771 1 Chicken Bowl \n", - "4444 1771 1 Chicken Bowl \n", - "4465 1779 1 Chicken Bowl \n", - "4481 1786 1 Chicken Bowl \n", - "4483 1786 1 Chicken Bowl \n", - "4484 1786 1 Chicken Bowl \n", - "4486 1786 1 Chicken Bowl \n", - "4488 1786 1 Chicken Bowl \n", - "4495 1788 1 Chicken Bowl \n", - "4498 1789 1 Chicken Bowl \n", - "4506 1792 1 Chicken Bowl \n", - "4511 1794 1 Chicken Bowl \n", - "4532 1802 1 Chicken Bowl \n", - "4537 1804 1 Chicken Bowl \n", - "4540 1805 1 Chicken Bowl \n", - "4553 1810 1 Chicken Bowl \n", - "4555 1811 1 Chicken Bowl \n", - "4564 1815 1 Chicken Bowl \n", - "4574 1819 1 Chicken Bowl \n", - "4576 1820 1 Chicken Bowl \n", - "4581 1822 1 Chicken Bowl \n", - "4583 1823 1 Chicken Bowl \n", - "4586 1824 1 Chicken Bowl \n", - "4587 1824 1 Chicken Bowl \n", - "4589 1825 1 Chicken Bowl \n", - "4590 1825 1 Chicken Bowl \n", - "4591 1825 1 Chicken Bowl \n", - "4595 1826 1 Chicken Bowl \n", - "4599 1827 1 Chicken Bowl \n", - "4604 1828 1 Chicken Bowl \n", + " item_name choice_description \\\n", + "0 Chicken Bowl [Fresh Tomato Salsa (Mild), [Rice, Cheese, Sou... \n", + "1 Steak Burrito [Tomatillo Red Chili Salsa, [Fajita Vegetables... \n", + "2 Chicken Bowl [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... \n", + "3 Chicken Burrito [[Tomatillo-Green Chili Salsa (Medium), Tomati... \n", + "4 Barbacoa Bowl [Roasted Chili Corn Salsa, [Fajita Vegetables,... \n", + ".. ... ... \n", + "702 Carnitas Bowl [Roasted Chili Corn Salsa, [Rice, Sour Cream, ... \n", + "703 Barbacoa Bowl [Roasted Chili Corn Salsa, [Pinto Beans, Sour ... \n", + "704 Steak Burrito [Tomatillo Green Chili Salsa, [Rice, Cheese, S... \n", + "705 Steak Burrito [Fresh Tomato Salsa, [Rice, Sour Cream, Cheese... \n", + "706 Veggie Burrito [Tomatillo Green Chili Salsa, [Rice, Fajita Ve... \n", "\n", - " choice_description item_price \n", - "5 [Fresh Tomato Salsa (Mild), [Rice, Cheese, Sou... 10.98 \n", - "13 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 11.25 \n", - "19 [Tomatillo Red Chili Salsa, [Fajita Vegetables... 8.75 \n", - "26 [Roasted Chili Corn Salsa (Medium), [Pinto Bea... 8.49 \n", - "42 [Roasted Chili Corn Salsa, [Rice, Black Beans,... 11.25 \n", - "76 [Fresh Tomato Salsa, [Rice, Black Beans, Pinto... 8.75 \n", - "78 [Fresh Tomato Salsa, [Rice, Black Beans, Chees... 8.75 \n", - "99 [Tomatillo Red Chili Salsa, [Rice, Fajita Vege... 8.75 \n", - "110 [Tomatillo Red Chili Salsa, [Rice, Black Beans... 8.75 \n", - "123 [Fresh Tomato Salsa, [Guacamole, Cheese, Sour ... 11.25 \n", - "138 [Fresh Tomato Salsa, [Rice, Fajita Vegetables,... 11.25 \n", - "140 [Tomatillo Green Chili Salsa, [Rice, Sour Crea... 11.25 \n", - "142 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 11.25 \n", - "160 [Fresh Tomato Salsa (Mild), [Black Beans, Rice... 8.49 \n", - "176 [Roasted Chili Corn Salsa (Medium), [Black Bea... 10.98 \n", - "182 [Fresh Tomato Salsa, [Rice, Black Beans, Sour ... 8.75 \n", - "193 [Fresh Tomato Salsa, [Rice, Cheese, Sour Cream]] 8.75 \n", - "199 [[Roasted Chili Corn Salsa (Medium), Tomatillo... 10.98 \n", - "206 [Fresh Tomato Salsa, [Rice, Cheese, Lettuce]] 8.75 \n", - "209 [Roasted Chili Corn Salsa, [Fajita Vegetables,... 11.25 \n", - "211 [Roasted Chili Corn Salsa, [Fajita Vegetables,... 11.25 \n", - "218 [Tomatillo Green Chili Salsa, [Rice, Black Bea... 8.75 \n", - "220 [Roasted Chili Corn Salsa, [Rice, Black Beans,... 8.75 \n", - "224 [Tomatillo Green Chili Salsa, [Rice, Pinto Bea... 8.75 \n", - "231 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 8.75 \n", - "252 [Tomatillo Red Chili Salsa, [Rice, Cheese, Let... 8.75 \n", - "257 [Fresh Tomato Salsa, [Rice, Black Beans, Cheese]] 8.75 \n", - "284 [Fresh Tomato Salsa, [Rice, Cheese, Sour Cream]] 8.75 \n", - "290 [Roasted Chili Corn Salsa, [Fajita Vegetables,... 11.25 \n", - "291 [Tomatillo Green Chili Salsa, [Rice, Sour Crea... 11.25 \n", - "... ... ... \n", - "4443 [Tomatillo Green Chili Salsa, [Rice, Pinto Bea... 8.75 \n", - "4444 [Fresh Tomato Salsa, [Rice, Black Beans, Sour ... 8.75 \n", - "4465 [Fresh Tomato Salsa, [Rice, Black Beans, Cheese]] 8.75 \n", - "4481 [Fresh Tomato Salsa, Rice] 8.75 \n", - "4483 [Fresh Tomato Salsa, [Rice, Pinto Beans, Chees... 11.25 \n", - "4484 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 11.25 \n", - "4486 [Fresh Tomato Salsa, [Rice, Black Beans, Chees... 11.25 \n", - "4488 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 8.75 \n", - "4495 [Fresh Tomato Salsa, [Rice, Pinto Beans, Sour ... 11.25 \n", - "4498 [Tomatillo Green Chili Salsa, [Fajita Vegetabl... 11.25 \n", - "4506 [Fresh Tomato Salsa, [Rice, Cheese, Sour Cream... 11.25 \n", - "4511 [Roasted Chili Corn Salsa, [Rice, Fajita Veget... 8.75 \n", - "4532 [Roasted Chili Corn Salsa, [Rice, Black Beans,... 8.75 \n", - "4537 [Fresh Tomato Salsa, [Rice, Black Beans, Chees... 8.75 \n", - "4540 [Tomatillo Green Chili Salsa, [Fajita Vegetabl... 11.25 \n", - "4553 [Roasted Chili Corn Salsa, [Black Beans, Sour ... 11.25 \n", - "4555 [Roasted Chili Corn Salsa, [Fajita Vegetables,... 8.75 \n", - "4564 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 11.25 \n", - "4574 [Roasted Chili Corn Salsa, [Rice, Cheese, Lett... 8.75 \n", - "4576 [Fresh Tomato Salsa, [Rice, Cheese, Sour Cream... 11.25 \n", - "4581 [Tomatillo Red Chili Salsa, [Rice, Black Beans... 8.75 \n", - "4583 [Tomatillo Green Chili Salsa, [Rice, Black Bea... 8.75 \n", - "4586 [Fresh Tomato Salsa, [Rice, Black Beans, Chees... 11.25 \n", - "4587 [Fresh Tomato Salsa, [Rice, Black Beans, Chees... 11.25 \n", - "4589 [Fresh Tomato Salsa, [Rice, Black Beans, Sour ... 11.25 \n", - "4590 [Roasted Chili Corn Salsa, [Rice, Black Beans,... 11.25 \n", - "4591 [Tomatillo Red Chili Salsa, [Rice, Black Beans... 8.75 \n", - "4595 [Tomatillo Green Chili Salsa, [Rice, Black Bea... 8.75 \n", - "4599 [Roasted Chili Corn Salsa, [Cheese, Lettuce]] 8.75 \n", - "4604 [Fresh Tomato Salsa, [Rice, Black Beans, Chees... 8.75 \n", + " product_price \n", + "0 10.98 \n", + "1 11.75 \n", + "2 11.25 \n", + "3 10.98 \n", + "4 11.75 \n", + ".. ... \n", + "702 11.75 \n", + "703 11.75 \n", + "704 11.75 \n", + "705 11.75 \n", + "706 11.25 \n", "\n", - "[693 rows x 5 columns]" + "[707 rows x 3 columns]" ] }, - "execution_count": 25, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "# delete the duplicates in item_name and quantity\n", - "# chipo_filtered = chipo.drop_duplicates(['item_name','quantity'])\n", - "chipo[(chipo['item_name'] == 'Chicken Bowl') & (chipo['quantity'] == 1)]\n", - "\n", - "# select only the products with quantity equals to 1\n", - "# chipo_one_prod = chipo_filtered[chipo_filtered.quantity == 1]\n", - "\n", - "# select only the item_name and item_price columns\n", - "# price_per_item = chipo_one_prod[['item_name', 'item_price']]\n", - "\n", - "# sort the values from the most to less expensive\n", - "# price_per_item.sort_values(by = \"item_price\", ascending = False).head(20)" + "filtered_chipo[[\"item_name\",\"choice_description\",\"product_price\"]]" ] }, { @@ -2089,52 +1521,22 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 14, "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", - "
order_idquantityitem_namechoice_descriptionitem_price
3598144315Chips and Fresh Tomato SalsaNaN44.25
\n", - "
" - ], "text/plain": [ - " order_id quantity item_name choice_description \\\n", - "3598 1443 15 Chips and Fresh Tomato Salsa NaN \n", - "\n", - " item_price \n", - "3598 44.25 " + "15" ] }, - "execution_count": 26, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "chipo.sort_values(by = \"item_price\", ascending = False).head(1)" + "chipo.loc[chipo[\"item_price\"].idxmax()][\"quantity\"]" ] }, { @@ -2146,7 +1548,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -2155,15 +1557,13 @@ "18" ] }, - "execution_count": 18, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "chipo_salad = chipo[chipo.item_name == \"Veggie Salad Bowl\"]\n", - "\n", - "len(chipo_salad)" + "chipo[chipo[\"item_name\"]==\"Veggie Salad Bowl\"][\"quantity\"].sum()" ] }, { @@ -2175,7 +1575,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -2184,21 +1584,20 @@ "20" ] }, - "execution_count": 28, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "chipo_drink_steak_bowl = chipo[(chipo.item_name == \"Canned Soda\") & (chipo.quantity > 1)]\n", - "len(chipo_drink_steak_bowl)" + "chipo[ ( chipo[\"item_name\"]==\"Canned Soda\" ) & ( chipo[\"quantity\"]>1 )].shape[0]" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python 3", + "display_name": "base", "language": "python", "name": "python3" }, @@ -2212,7 +1611,20 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.4" + "version": "3.12.3" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, diff --git a/02_Filtering_&_Sorting/Chipotle/Solutions.ipynb b/02_Filtering_&_Sorting/Chipotle/Solutions.ipynb index d21f74f3e..a8592d9ff 100644 --- a/02_Filtering_&_Sorting/Chipotle/Solutions.ipynb +++ b/02_Filtering_&_Sorting/Chipotle/Solutions.ipynb @@ -58,35 +58,27 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "metadata": { "collapsed": false }, "outputs": [ { - "data": { - "text/plain": [ - "12" - ] - }, - "execution_count": 22, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "the number of products that cost more than $10.00 is 707\n" + ] } ], "source": [ - "# clean the item_price column and transform it in a float\n", - "\n", - "\n", - "# reassign the column with the cleaned prices\n", + "# the item price column is actullay the price of the product multiplied by the quantity\n", "\n", + "# adding a new column representing the price of each single product in float\n", "\n", - "# delete the duplicates in item_name and quantity\n", + "# removing duplicated products\n", "\n", - "\n", - "# select only the products with quantity equals to 1\n", - "\n", - "\n" + "# filtering products that costs more than $10\n" ] }, { @@ -94,12 +86,12 @@ "metadata": {}, "source": [ "### Step 5. What is the price of each item? \n", - "###### print a data frame with only two columns item_name and item_price" + "###### print a data frame with only three columns item_name choice_description and product_price" ] }, { "cell_type": "code", - "execution_count": 24, + "execution_count": null, "metadata": { "collapsed": false }, @@ -108,160 +100,136 @@ "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", - " \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", "
item_nameitem_pricechoice_descriptionproduct_price
606Steak Salad Bowl11.89
1229Barbacoa Salad Bowl11.89
1132Carnitas Salad Bowl11.890Chicken Bowl[Fresh Tomato Salsa (Mild), [Rice, Cheese, Sou...10.98
71Steak Burrito[Tomatillo Red Chili Salsa, [Fajita Vegetables...11.75
168Barbacoa Crispy Tacos11.75
39Barbacoa Bowl11.75
738Veggie Soft Tacos11.25
186Veggie Salad Bowl11.25
62Veggie Bowl11.25
57Veggie Burrito2Chicken Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...11.25
250Chicken Salad10.98
5Chicken Bowl3Chicken Burrito[[Tomatillo-Green Chili Salsa (Medium), Tomati...10.98
8Steak Soft Tacos9.25
554Carnitas Crispy Tacos9.254Barbacoa Bowl[Roasted Chili Corn Salsa, [Fajita Vegetables,...11.75
237Carnitas Soft Tacos9.25............
56Barbacoa Soft Tacos9.25702Carnitas Bowl[Roasted Chili Corn Salsa, [Rice, Sour Cream, ...11.75
92Steak Crispy Tacos9.25703Barbacoa Bowl[Roasted Chili Corn Salsa, [Pinto Beans, Sour ...11.75
664Steak Salad8.99704Steak Burrito[Tomatillo Green Chili Salsa, [Rice, Cheese, S...11.75
54Steak Bowl8.99705Steak Burrito[Fresh Tomato Salsa, [Rice, Sour Cream, Cheese...11.75
3750Carnitas Salad8.99706Veggie Burrito[Tomatillo Green Chili Salsa, [Rice, Fajita Ve...11.25
\n", + "

707 rows × 3 columns

\n", "
" ], "text/plain": [ - " item_name item_price\n", - "606 Steak Salad Bowl 11.89\n", - "1229 Barbacoa Salad Bowl 11.89\n", - "1132 Carnitas Salad Bowl 11.89\n", - "7 Steak Burrito 11.75\n", - "168 Barbacoa Crispy Tacos 11.75\n", - "39 Barbacoa Bowl 11.75\n", - "738 Veggie Soft Tacos 11.25\n", - "186 Veggie Salad Bowl 11.25\n", - "62 Veggie Bowl 11.25\n", - "57 Veggie Burrito 11.25\n", - "250 Chicken Salad 10.98\n", - "5 Chicken Bowl 10.98\n", - "8 Steak Soft Tacos 9.25\n", - "554 Carnitas Crispy Tacos 9.25\n", - "237 Carnitas Soft Tacos 9.25\n", - "56 Barbacoa Soft Tacos 9.25\n", - "92 Steak Crispy Tacos 9.25\n", - "664 Steak Salad 8.99\n", - "54 Steak Bowl 8.99\n", - "3750 Carnitas Salad 8.99" + " item_name choice_description \\\n", + "0 Chicken Bowl [Fresh Tomato Salsa (Mild), [Rice, Cheese, Sou... \n", + "1 Steak Burrito [Tomatillo Red Chili Salsa, [Fajita Vegetables... \n", + "2 Chicken Bowl [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... \n", + "3 Chicken Burrito [[Tomatillo-Green Chili Salsa (Medium), Tomati... \n", + "4 Barbacoa Bowl [Roasted Chili Corn Salsa, [Fajita Vegetables,... \n", + ".. ... ... \n", + "702 Carnitas Bowl [Roasted Chili Corn Salsa, [Rice, Sour Cream, ... \n", + "703 Barbacoa Bowl [Roasted Chili Corn Salsa, [Pinto Beans, Sour ... \n", + "704 Steak Burrito [Tomatillo Green Chili Salsa, [Rice, Cheese, S... \n", + "705 Steak Burrito [Fresh Tomato Salsa, [Rice, Sour Cream, Cheese... \n", + "706 Veggie Burrito [Tomatillo Green Chili Salsa, [Rice, Fajita Ve... \n", + "\n", + " product_price \n", + "0 10.98 \n", + "1 11.75 \n", + "2 11.25 \n", + "3 10.98 \n", + "4 11.75 \n", + ".. ... \n", + "702 11.75 \n", + "703 11.75 \n", + "704 11.75 \n", + "705 11.75 \n", + "706 11.25 \n", + "\n", + "[707 rows x 3 columns]" ] }, - "execution_count": 24, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], - "source": [ - "# delete the duplicates in item_name and quantity\n", - "\n", - "\n", - "# select only the products with quantity equals to 1\n", - "\n", - "\n", - "# select only the item_name and item_price columns\n", - "\n", - "\n", - "# sort the values from the most to less expensive\n" - ] + "source": [] }, { "cell_type": "markdown", @@ -272,7 +240,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, "metadata": { "collapsed": false }, @@ -281,6 +249,19 @@ "data": { "text/html": [ "
\n", + "\n", "\n", " \n", " \n", @@ -290,6 +271,7 @@ " \n", " \n", " \n", + " \n", " \n", " \n", " \n", @@ -300,6 +282,7 @@ " \n", " \n", " \n", + " \n", " \n", " \n", " \n", @@ -308,6 +291,7 @@ " \n", " \n", " \n", + " \n", " \n", " \n", " \n", @@ -316,6 +300,7 @@ " \n", " \n", " \n", + " \n", " \n", " \n", " \n", @@ -324,6 +309,7 @@ " \n", " \n", " \n", + " \n", " \n", " \n", " \n", @@ -332,205 +318,6 @@ " \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", - " \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", @@ -540,206 +327,7 @@ " \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", - " \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", @@ -748,6 +336,7 @@ " \n", " \n", " \n", + " \n", " \n", " \n", " \n", @@ -756,6 +345,7 @@ " \n", " \n", " \n", + " \n", " \n", " \n", " \n", @@ -764,6 +354,7 @@ " \n", " \n", " \n", + " \n", " \n", " \n", " \n", @@ -772,6 +363,7 @@ " \n", " \n", " \n", + " \n", " \n", " \n", " \n", @@ -780,10 +372,11 @@ " \n", " \n", " \n", + " \n", " \n", " \n", "
item_namechoice_descriptionitem_priceproduct_price
6 Pack Soft Drink[Diet Coke]12.986.49
3416 Pack Soft Drink[Diet Coke]6.496.49
18496 Pack Soft Drink[Coke]6.496.49
18606 Pack Soft Drink[Diet Coke]6.496.49
27136 Pack Soft Drink[Coke]6.49
3422137316 Pack Soft Drink[Coke]6.49
55323016 Pack Soft Drink[Diet Coke]6.49
191677416 Pack Soft Drink[Diet Coke]6.49
192277616 Pack Soft Drink[Coke]6.49
193778416 Pack Soft Drink[Diet Coke]6.49
3836153716 Pack Soft Drink[Coke]6.49
29812916 Pack Soft Drink[Sprite]6.49
197679816 Pack Soft Drink[Diet Coke]6.49
116748116 Pack Soft Drink[Coke]6.49
3875155416 Pack Soft Drink[Diet Coke]6.49
112446516 Pack Soft Drink[Coke]6.49
3886155816 Pack Soft Drink[Diet Coke]6.49
210884916 Pack Soft Drink[Coke]6.49
3010119616 Pack Soft Drink[Diet Coke]6.49
4535180316 Pack Soft Drink[Lemonade]6.49
4169166416 Pack Soft Drink[Diet Coke]6.49
4174166616 Pack Soft Drink[Coke]6.49
4527180016 Pack Soft Drink[Diet Coke]6.49
4522179816 Pack Soft Drink[Diet Coke]6.49
3806152516 Pack Soft Drink[Sprite]6.49
238994916 Pack Soft Drink[Coke]6.49
3132124816 Pack Soft Drink[Diet Coke]6.49
3141125316 Pack Soft Drink[Lemonade]6.49
63926416 Pack Soft Drink[Diet Coke]6.49
102642216 Pack Soft Drink[Sprite]6.49
.........
299611921Veggie Salad[Roasted Chili Corn Salsa (Medium), [Black Bea...8.49
316312631Veggie Salad[[Fresh Tomato Salsa (Mild), Roasted Chili Cor...8.49
408416351Veggie Salad[[Fresh Tomato Salsa (Mild), Roasted Chili Cor...8.49
16946861Veggie Salad[[Fresh Tomato Salsa (Mild), Roasted Chili Cor...8.49
275610941Veggie Salad[[Tomatillo-Green Chili Salsa (Medium), Roaste...8.49
420116771Veggie Salad Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Black...11.25
18847601Veggie Salad Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...11.25
4551951Veggie Salad Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...11.25
322312891Veggie Salad Bowl[Tomatillo Red Chili Salsa, [Fajita Vegetables...11.25
22238961Veggie Salad Bowl[Roasted Chili Corn Salsa, Fajita Vegetables]8.75
22699131Veggie Salad Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...8.75
454118051Veggie Salad Bowl[Tomatillo Green Chili Salsa, [Fajita Vegetabl...8.75
329313211Veggie Salad Bowl[Fresh Tomato Salsa, [Rice, Black Beans, Chees...8.75
186831Veggie Salad Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...11.25
9603941Veggie Salad Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Lettu...8.75
13165361Veggie Salad Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...8.75
21568691Veggie Salad Bowl[Tomatillo Red Chili Salsa, [Fajita Vegetables...11.25
426117001Veggie Salad Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...11.25
2951281Veggie Salad Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Lettu...11.25
457318181Veggie Salad Bowl[Fresh Tomato Salsa, [Fajita Vegetables, Pinto...8.75
268310661Veggie Salad Bowl[Roasted Chili Corn Salsa, [Fajita Vegetables,...8.75
4962071Veggie Salad Bowl[Fresh Tomato Salsa, [Rice, Lettuce, Guacamole...11.25
410916461Veggie Salad Bowl[Tomatillo Red Chili Salsa, [Fajita Vegetables...11.25
7383041Veggie Soft Tacos[Tomatillo Red Chili Salsa, [Fajita Vegetables...11.25
388915592Veggie Soft Tacos[Fresh Tomato Salsa (Mild), [Black Beans, Rice...16.98...
2384Veggie Soft Tacos[Roasted Chili Corn Salsa, [Fajita Vegetables,...8.758.75
781Veggie Soft Tacos[Fresh Tomato Salsa, [Black Beans, Cheese, Sou...8.758.75
2851Veggie Soft Tacos[Roasted Chili Corn Salsa (Medium), [Black Bea...8.498.49
1699Veggie Soft Tacos[Fresh Tomato Salsa, [Fajita Vegetables, Rice,...11.2511.25
1395Veggie Soft Tacos[Fresh Tomato Salsa (Mild), [Pinto Beans, Rice...8.498.49
\n", - "

4622 rows × 5 columns

\n", + "

4622 rows × 6 columns

\n", "
" ], "text/plain": [ @@ -793,139 +386,50 @@ "1849 749 1 6 Pack Soft Drink \n", "1860 754 1 6 Pack Soft Drink \n", "2713 1076 1 6 Pack Soft Drink \n", - "3422 1373 1 6 Pack Soft Drink \n", - "553 230 1 6 Pack Soft Drink \n", - "1916 774 1 6 Pack Soft Drink \n", - "1922 776 1 6 Pack Soft Drink \n", - "1937 784 1 6 Pack Soft Drink \n", - "3836 1537 1 6 Pack Soft Drink \n", - "298 129 1 6 Pack Soft Drink \n", - "1976 798 1 6 Pack Soft Drink \n", - "1167 481 1 6 Pack Soft Drink \n", - "3875 1554 1 6 Pack Soft Drink \n", - "1124 465 1 6 Pack Soft Drink \n", - "3886 1558 1 6 Pack Soft Drink \n", - "2108 849 1 6 Pack Soft Drink \n", - "3010 1196 1 6 Pack Soft Drink \n", - "4535 1803 1 6 Pack Soft Drink \n", - "4169 1664 1 6 Pack Soft Drink \n", - "4174 1666 1 6 Pack Soft Drink \n", - "4527 1800 1 6 Pack Soft Drink \n", - "4522 1798 1 6 Pack Soft Drink \n", - "3806 1525 1 6 Pack Soft Drink \n", - "2389 949 1 6 Pack Soft Drink \n", - "3132 1248 1 6 Pack Soft Drink \n", - "3141 1253 1 6 Pack Soft Drink \n", - "639 264 1 6 Pack Soft Drink \n", - "1026 422 1 6 Pack Soft Drink \n", "... ... ... ... \n", - "2996 1192 1 Veggie Salad \n", - "3163 1263 1 Veggie Salad \n", - "4084 1635 1 Veggie Salad \n", - "1694 686 1 Veggie Salad \n", - "2756 1094 1 Veggie Salad \n", - "4201 1677 1 Veggie Salad Bowl \n", - "1884 760 1 Veggie Salad Bowl \n", - "455 195 1 Veggie Salad Bowl \n", - "3223 1289 1 Veggie Salad Bowl \n", - "2223 896 1 Veggie Salad Bowl \n", - "2269 913 1 Veggie Salad Bowl \n", - "4541 1805 1 Veggie Salad Bowl \n", - "3293 1321 1 Veggie Salad Bowl \n", - "186 83 1 Veggie Salad Bowl \n", - "960 394 1 Veggie Salad Bowl \n", - "1316 536 1 Veggie Salad Bowl \n", - "2156 869 1 Veggie Salad Bowl \n", - "4261 1700 1 Veggie Salad Bowl \n", - "295 128 1 Veggie Salad Bowl \n", - "4573 1818 1 Veggie Salad Bowl \n", - "2683 1066 1 Veggie Salad Bowl \n", - "496 207 1 Veggie Salad Bowl \n", - "4109 1646 1 Veggie Salad Bowl \n", - "738 304 1 Veggie Soft Tacos \n", - "3889 1559 2 Veggie Soft Tacos \n", "2384 948 1 Veggie Soft Tacos \n", "781 322 1 Veggie Soft Tacos \n", "2851 1132 1 Veggie Soft Tacos \n", "1699 688 1 Veggie Soft Tacos \n", "1395 567 1 Veggie Soft Tacos \n", "\n", - " choice_description item_price \n", - "3389 [Diet Coke] 12.98 \n", - "341 [Diet Coke] 6.49 \n", - "1849 [Coke] 6.49 \n", - "1860 [Diet Coke] 6.49 \n", - "2713 [Coke] 6.49 \n", - "3422 [Coke] 6.49 \n", - "553 [Diet Coke] 6.49 \n", - "1916 [Diet Coke] 6.49 \n", - "1922 [Coke] 6.49 \n", - "1937 [Diet Coke] 6.49 \n", - "3836 [Coke] 6.49 \n", - "298 [Sprite] 6.49 \n", - "1976 [Diet Coke] 6.49 \n", - "1167 [Coke] 6.49 \n", - "3875 [Diet Coke] 6.49 \n", - "1124 [Coke] 6.49 \n", - "3886 [Diet Coke] 6.49 \n", - "2108 [Coke] 6.49 \n", - "3010 [Diet Coke] 6.49 \n", - "4535 [Lemonade] 6.49 \n", - "4169 [Diet Coke] 6.49 \n", - "4174 [Coke] 6.49 \n", - "4527 [Diet Coke] 6.49 \n", - "4522 [Diet Coke] 6.49 \n", - "3806 [Sprite] 6.49 \n", - "2389 [Coke] 6.49 \n", - "3132 [Diet Coke] 6.49 \n", - "3141 [Lemonade] 6.49 \n", - "639 [Diet Coke] 6.49 \n", - "1026 [Sprite] 6.49 \n", - "... ... ... \n", - "2996 [Roasted Chili Corn Salsa (Medium), [Black Bea... 8.49 \n", - "3163 [[Fresh Tomato Salsa (Mild), Roasted Chili Cor... 8.49 \n", - "4084 [[Fresh Tomato Salsa (Mild), Roasted Chili Cor... 8.49 \n", - "1694 [[Fresh Tomato Salsa (Mild), Roasted Chili Cor... 8.49 \n", - "2756 [[Tomatillo-Green Chili Salsa (Medium), Roaste... 8.49 \n", - "4201 [Fresh Tomato Salsa, [Fajita Vegetables, Black... 11.25 \n", - "1884 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 11.25 \n", - "455 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 11.25 \n", - "3223 [Tomatillo Red Chili Salsa, [Fajita Vegetables... 11.25 \n", - "2223 [Roasted Chili Corn Salsa, Fajita Vegetables] 8.75 \n", - "2269 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 8.75 \n", - "4541 [Tomatillo Green Chili Salsa, [Fajita Vegetabl... 8.75 \n", - "3293 [Fresh Tomato Salsa, [Rice, Black Beans, Chees... 8.75 \n", - "186 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 11.25 \n", - "960 [Fresh Tomato Salsa, [Fajita Vegetables, Lettu... 8.75 \n", - "1316 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 8.75 \n", - "2156 [Tomatillo Red Chili Salsa, [Fajita Vegetables... 11.25 \n", - "4261 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 11.25 \n", - "295 [Fresh Tomato Salsa, [Fajita Vegetables, Lettu... 11.25 \n", - "4573 [Fresh Tomato Salsa, [Fajita Vegetables, Pinto... 8.75 \n", - "2683 [Roasted Chili Corn Salsa, [Fajita Vegetables,... 8.75 \n", - "496 [Fresh Tomato Salsa, [Rice, Lettuce, Guacamole... 11.25 \n", - "4109 [Tomatillo Red Chili Salsa, [Fajita Vegetables... 11.25 \n", - "738 [Tomatillo Red Chili Salsa, [Fajita Vegetables... 11.25 \n", - "3889 [Fresh Tomato Salsa (Mild), [Black Beans, Rice... 16.98 \n", - "2384 [Roasted Chili Corn Salsa, [Fajita Vegetables,... 8.75 \n", - "781 [Fresh Tomato Salsa, [Black Beans, Cheese, Sou... 8.75 \n", - "2851 [Roasted Chili Corn Salsa (Medium), [Black Bea... 8.49 \n", - "1699 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 11.25 \n", - "1395 [Fresh Tomato Salsa (Mild), [Pinto Beans, Rice... 8.49 \n", + " choice_description item_price \\\n", + "3389 [Diet Coke] 12.98 \n", + "341 [Diet Coke] 6.49 \n", + "1849 [Coke] 6.49 \n", + "1860 [Diet Coke] 6.49 \n", + "2713 [Coke] 6.49 \n", + "... ... ... \n", + "2384 [Roasted Chili Corn Salsa, [Fajita Vegetables,... 8.75 \n", + "781 [Fresh Tomato Salsa, [Black Beans, Cheese, Sou... 8.75 \n", + "2851 [Roasted Chili Corn Salsa (Medium), [Black Bea... 8.49 \n", + "1699 [Fresh Tomato Salsa, [Fajita Vegetables, Rice,... 11.25 \n", + "1395 [Fresh Tomato Salsa (Mild), [Pinto Beans, Rice... 8.49 \n", + "\n", + " product_price \n", + "3389 6.49 \n", + "341 6.49 \n", + "1849 6.49 \n", + "1860 6.49 \n", + "2713 6.49 \n", + "... ... \n", + "2384 8.75 \n", + "781 8.75 \n", + "2851 8.49 \n", + "1699 11.25 \n", + "1395 8.49 \n", "\n", - "[4622 rows x 5 columns]" + "[4622 rows x 6 columns]" ] }, - "execution_count": 25, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\n", - "\n", - "# OR\n", - "\n" + "# OR\n" ] }, { @@ -937,48 +441,18 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": null, "metadata": { "collapsed": false }, "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", - "
order_idquantityitem_namechoice_descriptionitem_price
3598144315Chips and Fresh Tomato SalsaNaN44.25
\n", - "
" - ], "text/plain": [ - " order_id quantity item_name choice_description \\\n", - "3598 1443 15 Chips and Fresh Tomato Salsa NaN \n", - "\n", - " item_price \n", - "3598 44.25 " + "15" ] }, - "execution_count": 26, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -994,7 +468,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": null, "metadata": { "collapsed": false }, @@ -1005,7 +479,7 @@ "18" ] }, - "execution_count": 27, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -1021,7 +495,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": null, "metadata": { "collapsed": false }, @@ -1032,7 +506,7 @@ "20" ] }, - "execution_count": 28, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -1043,21 +517,21 @@ "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python [default]", + "display_name": "base", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" + "pygments_lexer": "ipython3", + "version": "3.12.3" } }, "nbformat": 4, diff --git a/02_Filtering_&_Sorting/Euro12/Exercises_with_Solutions.ipynb b/02_Filtering_&_Sorting/Euro12/Exercises_with_Solutions.ipynb index 1fae2c983..29a9be096 100644 --- a/02_Filtering_&_Sorting/Euro12/Exercises_with_Solutions.ipynb +++ b/02_Filtering_&_Sorting/Euro12/Exercises_with_Solutions.ipynb @@ -4,7 +4,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Ex2 - Filtering and Sorting Data" + "# Ex2 - Filtering and Sorting Data\n", + "Check out [Euro 12 Exercises Video Tutorial](https://youtu.be/iqk5d48Qisg) to watch a data scientist go through the exercises" ] }, { @@ -19,9 +20,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "import pandas as pd" @@ -44,9 +43,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -583,9 +580,7 @@ { "cell_type": "code", "execution_count": 37, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -628,9 +623,7 @@ { "cell_type": "code", "execution_count": 43, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -657,9 +650,7 @@ { "cell_type": "code", "execution_count": 44, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -722,9 +713,7 @@ { "cell_type": "code", "execution_count": 82, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -883,7 +872,6 @@ "cell_type": "code", "execution_count": 56, "metadata": { - "collapsed": false, "scrolled": true }, "outputs": [ @@ -1040,9 +1028,7 @@ { "cell_type": "code", "execution_count": 55, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -1069,9 +1055,7 @@ { "cell_type": "code", "execution_count": 57, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -1201,9 +1185,7 @@ { "cell_type": "code", "execution_count": 66, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -1333,9 +1315,7 @@ { "cell_type": "code", "execution_count": 84, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -1579,9 +1559,7 @@ { "cell_type": "code", "execution_count": 86, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -2119,9 +2097,7 @@ { "cell_type": "code", "execution_count": 89, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -2177,23 +2153,36 @@ "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python [default]", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" + "pygments_lexer": "ipython3", + "version": "3.7.3" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/02_Filtering_&_Sorting/Fictional Army/Exercise.ipynb b/02_Filtering_&_Sorting/Fictional_Army/Exercise.ipynb similarity index 100% rename from 02_Filtering_&_Sorting/Fictional Army/Exercise.ipynb rename to 02_Filtering_&_Sorting/Fictional_Army/Exercise.ipynb diff --git a/02_Filtering_&_Sorting/Fictional Army/Exercise_with_solutions.ipynb b/02_Filtering_&_Sorting/Fictional_Army/Exercise_with_solutions.ipynb similarity index 99% rename from 02_Filtering_&_Sorting/Fictional Army/Exercise_with_solutions.ipynb rename to 02_Filtering_&_Sorting/Fictional_Army/Exercise_with_solutions.ipynb index 9d98ce4c0..a5ebfde1e 100644 --- a/02_Filtering_&_Sorting/Fictional Army/Exercise_with_solutions.ipynb +++ b/02_Filtering_&_Sorting/Fictional_Army/Exercise_with_solutions.ipynb @@ -4,7 +4,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Fictional Army - Filtering and Sorting" + "# Fictional Army - Filtering and Sorting\n", + "Check out [Fictional Army Exercises Video Tutorial](https://youtu.be/42LGuRea7DE) to watch a data scientist go through the exercises" ] }, { @@ -1939,6 +1940,19 @@ "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, diff --git a/02_Filtering_&_Sorting/Fictional Army/Solutions.ipynb b/02_Filtering_&_Sorting/Fictional_Army/Solutions.ipynb similarity index 67% rename from 02_Filtering_&_Sorting/Fictional Army/Solutions.ipynb rename to 02_Filtering_&_Sorting/Fictional_Army/Solutions.ipynb index 9d98ce4c0..35af61602 100644 --- a/02_Filtering_&_Sorting/Fictional Army/Solutions.ipynb +++ b/02_Filtering_&_Sorting/Fictional_Army/Solutions.ipynb @@ -22,7 +22,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -38,7 +38,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -66,11 +66,233 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [ { "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "regiment", + "rawType": "object", + "type": "string" + }, + { + "name": "company", + "rawType": "object", + "type": "string" + }, + { + "name": "deaths", + "rawType": "int64", + "type": "integer" + }, + { + "name": "battles", + "rawType": "int64", + "type": "integer" + }, + { + "name": "size", + "rawType": "int64", + "type": "integer" + }, + { + "name": "veterans", + "rawType": "int64", + "type": "integer" + }, + { + "name": "readiness", + "rawType": "int64", + "type": "integer" + }, + { + "name": "armored", + "rawType": "int64", + "type": "integer" + }, + { + "name": "deserters", + "rawType": "int64", + "type": "integer" + }, + { + "name": "origin", + "rawType": "object", + "type": "string" + } + ], + "ref": "4131b398-c689-4291-9b0d-3a2f41947ee3", + "rows": [ + [ + "0", + "Nighthawks", + "1st", + "523", + "5", + "1045", + "1", + "1", + "1", + "4", + "Arizona" + ], + [ + "1", + "Nighthawks", + "1st", + "52", + "42", + "957", + "5", + "2", + "0", + "24", + "California" + ], + [ + "2", + "Nighthawks", + "2nd", + "25", + "2", + "1099", + "62", + "3", + "1", + "31", + "Texas" + ], + [ + "3", + "Nighthawks", + "2nd", + "616", + "2", + "1400", + "26", + "3", + "1", + "2", + "Florida" + ], + [ + "4", + "Dragoons", + "1st", + "43", + "4", + "1592", + "73", + "2", + "0", + "3", + "Maine" + ], + [ + "5", + "Dragoons", + "1st", + "234", + "7", + "1006", + "37", + "1", + "1", + "4", + "Iowa" + ], + [ + "6", + "Dragoons", + "2nd", + "523", + "8", + "987", + "949", + "2", + "0", + "24", + "Alaska" + ], + [ + "7", + "Dragoons", + "2nd", + "62", + "3", + "849", + "48", + "3", + "1", + "31", + "Washington" + ], + [ + "8", + "Scouts", + "1st", + "62", + "4", + "973", + "48", + "2", + "0", + "2", + "Oregon" + ], + [ + "9", + "Scouts", + "1st", + "73", + "7", + "1005", + "435", + "1", + "0", + "3", + "Wyoming" + ], + [ + "10", + "Scouts", + "2nd", + "37", + "8", + "1099", + "63", + "2", + "1", + "2", + "Louisana" + ], + [ + "11", + "Scouts", + "2nd", + "35", + "9", + "1523", + "345", + "3", + "1", + "3", + "Georgia" + ] + ], + "shape": { + "columns": 10, + "rows": 12 + } + }, "text/html": [ "
\n", "\n", "\n", " \n", " \n", @@ -137,7 +152,7 @@ } ], "source": [ - "drinks = pd.read_csv('https://raw.githubusercontent.com/justmarkham/DAT8/master/data/drinks.csv')\n", + "drinks = pd.read_csv('https://raw.githubusercontent.com/justmarkham/DAT8/master/data/drinks.csv',keep_default_na=False)\n", "drinks.head()" ] }, @@ -150,7 +165,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -160,12 +175,13 @@ "AF 61.471698\n", "AS 37.045455\n", "EU 193.777778\n", + "NA 145.434783\n", "OC 89.687500\n", "SA 175.083333\n", "Name: beer_servings, dtype: float64" ] }, - "execution_count": 6, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -183,57 +199,134 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 6, "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", + "
countmeanstdmin25%50%75%max
continent
AF53.016.26415138.8464190.01.02.013.00233.0
AS44.09.06818221.6670340.00.01.08.00123.0
EU45.0142.22222297.4217380.059.0128.0195.00370.0
NA23.024.52173928.2663781.05.011.034.00100.0
OC16.035.62500064.5557900.01.08.523.25212.0
SA12.062.41666788.6201891.03.012.098.50221.0
\n", + "
" + ], "text/plain": [ - "continent \n", - "AF count 53.000000\n", - " mean 16.264151\n", - " std 38.846419\n", - " min 0.000000\n", - " 25% 1.000000\n", - " 50% 2.000000\n", - " 75% 13.000000\n", - " max 233.000000\n", - "AS count 44.000000\n", - " mean 9.068182\n", - " std 21.667034\n", - " min 0.000000\n", - " 25% 0.000000\n", - " 50% 1.000000\n", - " 75% 8.000000\n", - " max 123.000000\n", - "EU count 45.000000\n", - " mean 142.222222\n", - " std 97.421738\n", - " min 0.000000\n", - " 25% 59.000000\n", - " 50% 128.000000\n", - " 75% 195.000000\n", - " max 370.000000\n", - "OC count 16.000000\n", - " mean 35.625000\n", - " std 64.555790\n", - " min 0.000000\n", - " 25% 1.000000\n", - " 50% 8.500000\n", - " 75% 23.250000\n", - " max 212.000000\n", - "SA count 12.000000\n", - " mean 62.416667\n", - " std 88.620189\n", - " min 1.000000\n", - " 25% 3.000000\n", - " 50% 12.000000\n", - " 75% 98.500000\n", - " max 221.000000\n", - "dtype: float64" + " count mean std min 25% 50% 75% max\n", + "continent \n", + "AF 53.0 16.264151 38.846419 0.0 1.0 2.0 13.00 233.0\n", + "AS 44.0 9.068182 21.667034 0.0 0.0 1.0 8.00 123.0\n", + "EU 45.0 142.222222 97.421738 0.0 59.0 128.0 195.00 370.0\n", + "NA 23.0 24.521739 28.266378 1.0 5.0 11.0 34.00 100.0\n", + "OC 16.0 35.625000 64.555790 0.0 1.0 8.5 23.25 212.0\n", + "SA 12.0 62.416667 88.620189 1.0 3.0 12.0 98.50 221.0" ] }, - "execution_count": 9, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -251,13 +344,26 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "\n", " \n", " \n", @@ -298,6 +404,13 @@ " \n", " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -321,6 +434,7 @@ "AF 61.471698 16.339623 16.264151 \n", "AS 37.045455 60.840909 9.068182 \n", "EU 193.777778 132.555556 142.222222 \n", + "NA 145.434783 165.739130 24.521739 \n", "OC 89.687500 58.437500 35.625000 \n", "SA 175.083333 114.750000 62.416667 \n", "\n", @@ -329,17 +443,18 @@ "AF 3.007547 \n", "AS 2.170455 \n", "EU 8.617778 \n", + "NA 5.995652 \n", "OC 3.381250 \n", "SA 6.308333 " ] }, - "execution_count": 10, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "drinks.groupby('continent').mean()" + "drinks.groupby('continent').mean(numeric_only=True)" ] }, { @@ -351,13 +466,26 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "
8.617778
NA145.434783165.73913024.5217395.995652
OC89.68750058.437500
\n", " \n", " \n", @@ -398,6 +526,13 @@ " \n", " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -421,6 +556,7 @@ "AF 32.0 3.0 2.0 \n", "AS 17.5 16.0 1.0 \n", "EU 219.0 122.0 128.0 \n", + "NA 143.0 137.0 11.0 \n", "OC 52.5 37.0 8.5 \n", "SA 162.5 108.5 12.0 \n", "\n", @@ -429,36 +565,50 @@ "AF 2.30 \n", "AS 1.20 \n", "EU 10.00 \n", + "NA 6.30 \n", "OC 1.75 \n", "SA 6.85 " ] }, - "execution_count": 14, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "drinks.groupby('continent').median()" + "drinks.groupby('continent').median(numeric_only=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 8. Print the mean, min and max values for spirit consumption.\n", + "### Step 8. Print the mean, min and max values for spirit consumption for each Continent.\n", "#### This time output a DataFrame" ] }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "
10.00
NA143.0137.011.06.30
OC52.537.0
\n", " \n", " \n", @@ -494,6 +644,12 @@ " \n", " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -515,11 +671,12 @@ "AF 16.339623 0 152\n", "AS 60.840909 0 326\n", "EU 132.555556 0 373\n", + "NA 165.739130 68 438\n", "OC 58.437500 0 254\n", "SA 114.750000 25 302" ] }, - "execution_count": 15, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -527,27 +684,47 @@ "source": [ "drinks.groupby('continent').spirit_servings.agg(['mean', 'min', 'max'])" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3 (ipykernel)", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.16" + "pygments_lexer": "ipython3", + "version": "3.12.6" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 4 } diff --git a/03_Grouping/Alcohol_Consumption/Solutions.ipynb b/03_Grouping/Alcohol_Consumption/Solutions.ipynb index 3783e0b23..61da21c51 100644 --- a/03_Grouping/Alcohol_Consumption/Solutions.ipynb +++ b/03_Grouping/Alcohol_Consumption/Solutions.ipynb @@ -39,7 +39,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 3. Assign it to a variable called drinks." + "### Step 3. Assign it to a variable called drinks (Watch the values of the Column 'Continent' NA (North America), and how Pandas interprets it!" ] }, { @@ -433,7 +433,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 8. Print the mean, min and max values for spirit consumption.\n", + "### Step 8. Print the mean, min and max values for spirit consumption by Continent.\n", "#### This time output a DataFrame" ] }, diff --git a/03_Grouping/Occupation/Exercises_with_solutions.ipynb b/03_Grouping/Occupation/Exercises_with_solutions.ipynb index 9fb68d237..1f8e419c5 100644 --- a/03_Grouping/Occupation/Exercises_with_solutions.ipynb +++ b/03_Grouping/Occupation/Exercises_with_solutions.ipynb @@ -4,7 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Occupation" + "# Occupation\n", + "\n", + "Check out [Occupation Exercises Video Tutorial](https://youtu.be/jL3EVCoYIJQ) to watch a data scientist go through the exercises" ] }, { @@ -21,9 +23,7 @@ { "cell_type": "code", "execution_count": 64, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "import pandas as pd" @@ -46,9 +46,7 @@ { "cell_type": "code", "execution_count": 65, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -142,9 +140,7 @@ { "cell_type": "code", "execution_count": 66, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -193,9 +189,7 @@ { "cell_type": "code", "execution_count": 150, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -257,9 +251,7 @@ { "cell_type": "code", "execution_count": 151, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -433,9 +425,7 @@ { "cell_type": "code", "execution_count": 152, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -504,9 +494,7 @@ { "cell_type": "code", "execution_count": 154, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -578,23 +566,36 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" + "pygments_lexer": "ipython3", + "version": "3.7.3" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/03_Grouping/Regiment/Exercises_solutions.ipynb b/03_Grouping/Regiment/Exercises_solutions.ipynb index f71a8519d..00e825065 100644 --- a/03_Grouping/Regiment/Exercises_solutions.ipynb +++ b/03_Grouping/Regiment/Exercises_solutions.ipynb @@ -4,7 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Regiment" + "# Regiment\n", + "\n", + "Check out [Regiment Exercises Video Tutorial](https://youtu.be/MFZ3uakwAEk) to watch a data scientist go through the exercises" ] }, { @@ -21,9 +23,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "import pandas as pd" @@ -62,9 +62,7 @@ { "cell_type": "code", "execution_count": 6, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -218,9 +216,7 @@ { "cell_type": "code", "execution_count": 26, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -286,9 +282,7 @@ { "cell_type": "code", "execution_count": 29, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -436,9 +430,7 @@ { "cell_type": "code", "execution_count": 33, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -468,9 +460,7 @@ { "cell_type": "code", "execution_count": 35, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -504,9 +494,7 @@ { "cell_type": "code", "execution_count": 36, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -572,9 +560,7 @@ { "cell_type": "code", "execution_count": 37, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -663,9 +649,7 @@ { "cell_type": "code", "execution_count": 41, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -699,9 +683,7 @@ { "cell_type": "code", "execution_count": 50, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -740,23 +722,36 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" + "pygments_lexer": "ipython3", + "version": "3.7.3" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/04_Apply/US_Crime_Rates/Exercises_with_solutions.ipynb b/04_Apply/US_Crime_Rates/Exercises_with_solutions.ipynb index 8e807b326..ea83f0355 100644 --- a/04_Apply/US_Crime_Rates/Exercises_with_solutions.ipynb +++ b/04_Apply/US_Crime_Rates/Exercises_with_solutions.ipynb @@ -4,7 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# United States - Crime Rates - 1960 - 2014" + "# United States - Crime Rates - 1960 - 2014\n", + "\n", + "Check out [Crime Rates Exercises Video Tutorial](https://youtu.be/46lmk1JvcWA) to watch a data scientist go through the exercises" ] }, { @@ -22,10 +24,10 @@ }, { "cell_type": "code", - "execution_count": 95, - "metadata": { - "collapsed": false - }, + "execution_count": 1, + + + "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", @@ -48,15 +50,28 @@ }, { "cell_type": "code", - "execution_count": 265, - "metadata": { - "collapsed": false - }, + + "execution_count": 2, + + "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "
373
NA165.73913068438
OC58.4375000
\n", " \n", " \n", @@ -171,7 +186,7 @@ "4 130390 203050 1213200 2514400 472800 " ] }, - "execution_count": 265, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -191,10 +206,11 @@ }, { "cell_type": "code", - "execution_count": 266, - "metadata": { - "collapsed": false - }, + + "execution_count": 3, + + + "metadata": {}, "outputs": [ { "name": "stdout", @@ -203,20 +219,22 @@ "\n", "RangeIndex: 55 entries, 0 to 54\n", "Data columns (total 12 columns):\n", - "Year 55 non-null int64\n", - "Population 55 non-null int64\n", - "Total 55 non-null int64\n", - "Violent 55 non-null int64\n", - "Property 55 non-null int64\n", - "Murder 55 non-null int64\n", - "Forcible_Rape 55 non-null int64\n", - "Robbery 55 non-null int64\n", - "Aggravated_assault 55 non-null int64\n", - "Burglary 55 non-null int64\n", - "Larceny_Theft 55 non-null int64\n", - "Vehicle_Theft 55 non-null int64\n", + " # Column Non-Null Count Dtype\n", + "--- ------ -------------- -----\n", + " 0 Year 55 non-null int64\n", + " 1 Population 55 non-null int64\n", + " 2 Total 55 non-null int64\n", + " 3 Violent 55 non-null int64\n", + " 4 Property 55 non-null int64\n", + " 5 Murder 55 non-null int64\n", + " 6 Forcible_Rape 55 non-null int64\n", + " 7 Robbery 55 non-null int64\n", + " 8 Aggravated_assault 55 non-null int64\n", + " 9 Burglary 55 non-null int64\n", + " 10 Larceny_Theft 55 non-null int64\n", + " 11 Vehicle_Theft 55 non-null int64\n", "dtypes: int64(12)\n", - "memory usage: 5.2 KB\n" + "memory usage: 5.3 KB\n" ] } ], @@ -235,10 +253,10 @@ }, { "cell_type": "code", - "execution_count": 267, - "metadata": { - "collapsed": false - }, + + "execution_count": 4, + + "metadata": {}, "outputs": [ { "name": "stdout", @@ -247,20 +265,22 @@ "\n", "RangeIndex: 55 entries, 0 to 54\n", "Data columns (total 12 columns):\n", - "Year 55 non-null datetime64[ns]\n", - "Population 55 non-null int64\n", - "Total 55 non-null int64\n", - "Violent 55 non-null int64\n", - "Property 55 non-null int64\n", - "Murder 55 non-null int64\n", - "Forcible_Rape 55 non-null int64\n", - "Robbery 55 non-null int64\n", - "Aggravated_assault 55 non-null int64\n", - "Burglary 55 non-null int64\n", - "Larceny_Theft 55 non-null int64\n", - "Vehicle_Theft 55 non-null int64\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 Year 55 non-null datetime64[ns]\n", + " 1 Population 55 non-null int64 \n", + " 2 Total 55 non-null int64 \n", + " 3 Violent 55 non-null int64 \n", + " 4 Property 55 non-null int64 \n", + " 5 Murder 55 non-null int64 \n", + " 6 Forcible_Rape 55 non-null int64 \n", + " 7 Robbery 55 non-null int64 \n", + " 8 Aggravated_assault 55 non-null int64 \n", + " 9 Burglary 55 non-null int64 \n", + " 10 Larceny_Theft 55 non-null int64 \n", + " 11 Vehicle_Theft 55 non-null int64 \n", "dtypes: datetime64[ns](1), int64(11)\n", - "memory usage: 5.2 KB\n" + "memory usage: 5.3 KB\n" ] } ], @@ -279,15 +299,28 @@ }, { "cell_type": "code", - "execution_count": 268, - "metadata": { - "collapsed": false - }, + + "execution_count": 5, + + "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -420,7 +453,7 @@ "1964-01-01 472800 " ] }, - "execution_count": 268, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -439,15 +472,28 @@ }, { "cell_type": "code", - "execution_count": 269, - "metadata": { - "collapsed": false - }, + + "execution_count": 6, + + "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -565,7 +611,7 @@ "1964-01-01 203050 1213200 2514400 472800 " ] }, - "execution_count": 269, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -586,9 +632,8 @@ }, { "cell_type": "code", - "execution_count": 270, + "execution_count": 7, "metadata": { - "collapsed": false, "scrolled": true }, "outputs": [ @@ -596,6 +641,19 @@ "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -611,10 +669,23 @@ " \n", " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -627,7 +698,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -640,7 +711,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -653,7 +724,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -666,7 +737,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -679,7 +750,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -696,24 +767,26 @@ "" ], "text/plain": [ - " Population Violent Property Murder Forcible_Rape Robbery \\\n", - "1960 201385000 4134930 45160900 106180 236720 1633510 \n", - "1970 220099000 9607930 91383800 192230 554570 4159020 \n", - "1980 248239000 14074328 117048900 206439 865639 5383109 \n", - "1990 272690813 17527048 119053499 211664 998827 5748930 \n", - "2000 307006550 13968056 100944369 163068 922499 4230366 \n", - "2010 318857056 6072017 44095950 72867 421059 1749809 \n", + " Population Violent Property Murder Forcible_Rape Robbery \\\n", + "Year \n", + "1960-01-01 201385000 4134930 45160900 106180 236720 1633510 \n", + "1970-01-01 220099000 9607930 91383800 192230 554570 4159020 \n", + "1980-01-01 248239000 14074328 117048900 206439 865639 5383109 \n", + "1990-01-01 272690813 17527048 119053499 211664 998827 5748930 \n", + "2000-01-01 307006550 13968056 100944369 163068 922499 4230366 \n", + "2010-01-01 318857056 6072017 44095950 72867 421059 1749809 \n", "\n", - " Aggravated_assault Burglary Larceny_Theft Vehicle_Theft \n", - "1960 2158520 13321100 26547700 5292100 \n", - "1970 4702120 28486000 53157800 9739900 \n", - "1980 7619130 33073494 72040253 11935411 \n", - "1990 10568963 26750015 77679366 14624418 \n", - "2000 8652124 21565176 67970291 11412834 \n", - "2010 3764142 10125170 30401698 3569080 " + " Aggravated_assault Burglary Larceny_Theft Vehicle_Theft \n", + "Year \n", + "1960-01-01 2158520 13321100 26547700 5292100 \n", + "1970-01-01 4702120 28486000 53157800 9739900 \n", + "1980-01-01 7619130 33073494 72040253 11935411 \n", + "1990-01-01 10568963 26750015 77679366 14624418 \n", + "2000-01-01 8652124 21565176 67970291 11412834 \n", + "2010-01-01 3764142 10125170 30401698 3569080 " ] }, - "execution_count": 270, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -743,58 +816,81 @@ }, { "cell_type": "code", - "execution_count": 276, - "metadata": { - "collapsed": false - }, + + "execution_count": 9, + + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "Population 2010\n", - "Violent 1990\n", - "Property 1990\n", - "Murder 1990\n", - "Forcible_Rape 1990\n", - "Robbery 1990\n", - "Aggravated_assault 1990\n", - "Burglary 1980\n", - "Larceny_Theft 1990\n", - "Vehicle_Theft 1990\n", - "dtype: int64" + "Population 2010-01-01\n", + "Violent 1990-01-01\n", + "Property 1990-01-01\n", + "Murder 1990-01-01\n", + "Forcible_Rape 1990-01-01\n", + "Robbery 1990-01-01\n", + "Aggravated_assault 1990-01-01\n", + "Burglary 1980-01-01\n", + "Larceny_Theft 1990-01-01\n", + "Vehicle_Theft 1990-01-01\n", + "dtype: datetime64[ns]" ] }, - "execution_count": 276, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# apparently the 90s was a pretty dangerous time in the US\n", - "crime.idxmax(0)" + "crimes.idxmax(0)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python [default]", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" + "pygments_lexer": "ipython3", + + "version": "3.7.6" + + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false + } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/05_Merge/Fictitous Names/Exercises.ipynb b/05_Merge/Fictitous_Names/Exercises.ipynb similarity index 100% rename from 05_Merge/Fictitous Names/Exercises.ipynb rename to 05_Merge/Fictitous_Names/Exercises.ipynb diff --git a/05_Merge/Fictitous Names/Exercises_with_solutions.ipynb b/05_Merge/Fictitous_Names/Exercises_with_solutions.ipynb similarity index 96% rename from 05_Merge/Fictitous Names/Exercises_with_solutions.ipynb rename to 05_Merge/Fictitous_Names/Exercises_with_solutions.ipynb index 1f89f05b6..a4d5a6c7c 100644 --- a/05_Merge/Fictitous Names/Exercises_with_solutions.ipynb +++ b/05_Merge/Fictitous_Names/Exercises_with_solutions.ipynb @@ -4,7 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Fictitious Names" + "# Fictitious Names\n", + "\n", + "Check out [Fictitious Names Exercises Video Tutorial](https://youtu.be/6DbgcHBiOqo) to watch a data scientist go through the exercises" ] }, { @@ -26,9 +28,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "import pandas as pd" @@ -74,9 +74,7 @@ { "cell_type": "code", "execution_count": 12, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -182,9 +180,7 @@ { "cell_type": "code", "execution_count": 9, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -298,9 +294,7 @@ { "cell_type": "code", "execution_count": 10, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -397,9 +391,7 @@ { "cell_type": "code", "execution_count": 13, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -501,9 +493,7 @@ { "cell_type": "code", "execution_count": 15, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -619,9 +609,7 @@ { "cell_type": "code", "execution_count": 16, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -684,9 +672,7 @@ { "cell_type": "code", "execution_count": 17, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -796,23 +782,36 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" + "pygments_lexer": "ipython3", + "version": "3.7.3" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/05_Merge/Fictitous Names/Solutions.ipynb b/05_Merge/Fictitous_Names/Solutions.ipynb similarity index 100% rename from 05_Merge/Fictitous Names/Solutions.ipynb rename to 05_Merge/Fictitous_Names/Solutions.ipynb diff --git a/05_Merge/Housing Market/Exercises.ipynb b/05_Merge/Housing_Market/Exercises.ipynb similarity index 100% rename from 05_Merge/Housing Market/Exercises.ipynb rename to 05_Merge/Housing_Market/Exercises.ipynb diff --git a/05_Merge/Housing Market/Exercises_with_solutions.ipynb b/05_Merge/Housing_Market/Exercises_with_solutions.ipynb similarity index 100% rename from 05_Merge/Housing Market/Exercises_with_solutions.ipynb rename to 05_Merge/Housing_Market/Exercises_with_solutions.ipynb diff --git a/05_Merge/Housing Market/Solutions.ipynb b/05_Merge/Housing_Market/Solutions.ipynb similarity index 100% rename from 05_Merge/Housing Market/Solutions.ipynb rename to 05_Merge/Housing_Market/Solutions.ipynb diff --git a/06_Stats/.DS_Store b/06_Stats/.DS_Store new file mode 100644 index 000000000..c6834ab1c Binary files /dev/null and b/06_Stats/.DS_Store differ diff --git a/06_Stats/US_Baby_Names/Exercises.ipynb b/06_Stats/US_Baby_Names/Exercises.ipynb index f9f79e7ae..f6f75016f 100644 --- a/06_Stats/US_Baby_Names/Exercises.ipynb +++ b/06_Stats/US_Baby_Names/Exercises.ipynb @@ -23,9 +23,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -46,9 +44,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -62,9 +58,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -78,9 +72,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -88,15 +80,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 6. Is there more male or female names in the dataset?" + "### Step 6. What year has the highest number of baby names in the dataset?" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -104,15 +94,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 7. Group the dataset by name and assign to names" + "### Step 7. Is there more male or female names in the dataset?" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -120,15 +108,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 8. How many different names exist in the dataset?" + "### Step 8. Group the dataset by name and assign to names" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -136,15 +122,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 9. What is the name with most occurrences?" + "### Step 9. How many different names exist in the dataset?" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -152,15 +136,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 10. How many different names have the least occurrences?" + "### Step 10. What is the name with most occurrences?" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -168,15 +150,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 11. What is the median name occurrence?" + "### Step 11. How many different names have the least occurrences?" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -184,15 +164,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 12. What is the standard deviation of names?" + "### Step 12. What is the median name occurrence?" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -200,15 +178,27 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 13. Get a summary with the mean, min, max, std and quartiles." + "### Step 13. What is the standard deviation of names?" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 14. Get a summary with the mean, min, max, std and quartiles." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, "outputs": [], "source": [] } @@ -216,23 +206,23 @@ "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python [default]", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" + "pygments_lexer": "ipython3", + "version": "3.9.1" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/06_Stats/US_Baby_Names/Exercises_with_solutions.ipynb b/06_Stats/US_Baby_Names/Exercises_with_solutions.ipynb index 56234726f..5ae8e7175 100644 --- a/06_Stats/US_Baby_Names/Exercises_with_solutions.ipynb +++ b/06_Stats/US_Baby_Names/Exercises_with_solutions.ipynb @@ -4,7 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# US - Baby Names" + "# US - Baby Names\n", + "\n", + "Check out [Baby Names Exercises Video Tutorial](https://youtu.be/Daf2QNAy-qA) to watch a data scientist go through the exercises" ] }, { @@ -23,9 +25,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "import pandas as pd" @@ -48,9 +48,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -59,13 +57,15 @@ "\n", "RangeIndex: 1016395 entries, 0 to 1016394\n", "Data columns (total 7 columns):\n", - "Unnamed: 0 1016395 non-null int64\n", - "Id 1016395 non-null int64\n", - "Name 1016395 non-null object\n", - "Year 1016395 non-null int64\n", - "Gender 1016395 non-null object\n", - "State 1016395 non-null object\n", - "Count 1016395 non-null int64\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 Unnamed: 0 1016395 non-null int64 \n", + " 1 Id 1016395 non-null int64 \n", + " 2 Name 1016395 non-null object\n", + " 3 Year 1016395 non-null int64 \n", + " 4 Gender 1016395 non-null object\n", + " 5 State 1016395 non-null object\n", + " 6 Count 1016395 non-null int64 \n", "dtypes: int64(4), object(3)\n", "memory usage: 54.3+ MB\n" ] @@ -86,14 +86,25 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "
Larceny_TheftVehicle_Theft
Year
19601960-01-012013850004134930451609005292100
19701970-01-012200990009607930913838009739900
19801980-01-012482390001407432811704890011935411
19901990-01-012726908131752704811905349914624418
20002000-01-013070065501396805610094436911412834
20102010-01-01318857056607201744095950
\n", " \n", " \n", @@ -245,14 +256,25 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -337,15 +359,41 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 6. Are there more male or female names in the dataset?" + "### Step 6. What year has the highest number of baby names in the dataset?" ] }, { "cell_type": "code", "execution_count": 5, - "metadata": { - "collapsed": false - }, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Count 2007\n", + "dtype: int64" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "baby_names.groupby(\"Year\").sum().idxmax()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 7. Are there more male or female names in the dataset?" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, "outputs": [ { "data": { @@ -355,7 +403,7 @@ "Name: Gender, dtype: int64" ] }, - "execution_count": 5, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -368,15 +416,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 7. Group the dataset by name and assign to names" + "### Step 8. Group the dataset by name and assign to names" ] }, { "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, + "execution_count": 7, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -389,6 +435,19 @@ "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -435,7 +494,7 @@ "Isabella 204798" ] }, - "execution_count": 6, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -461,15 +520,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 8. How many different names exist in the dataset?" + "### Step 9. How many different names exist in the dataset?" ] }, { "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, + "execution_count": 8, + "metadata": {}, "outputs": [ { "data": { @@ -477,7 +534,7 @@ "17632" ] }, - "execution_count": 7, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -492,15 +549,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 9. What is the name with most occurrences?" + "### Step 10. What is the name with most occurrences?" ] }, { "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, + "execution_count": 9, + "metadata": {}, "outputs": [ { "data": { @@ -508,7 +563,7 @@ "'Jacob'" ] }, - "execution_count": 8, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -525,15 +580,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 10. How many different names have the least occurrences?" + "### Step 11. How many different names have the least occurrences?" ] }, { "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, + "execution_count": 10, + "metadata": {}, "outputs": [ { "data": { @@ -541,7 +594,7 @@ "2578" ] }, - "execution_count": 9, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -554,20 +607,31 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 11. What is the median name occurrence?" + "### Step 12. What is the median name occurrence?" ] }, { "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, + "execution_count": 11, + "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -601,210 +665,10 @@ " \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", - " \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", @@ -830,74 +694,24 @@ "" ], "text/plain": [ - " Count\n", - "Name \n", - "Aishani 49\n", - "Alara 49\n", - "Alysse 49\n", - "Ameir 49\n", - "Anely 49\n", - "Antonina 49\n", - "Aveline 49\n", - "Aziah 49\n", - "Baily 49\n", - "Caleah 49\n", - "Carlota 49\n", - "Cristine 49\n", - "Dahlila 49\n", - "Darvin 49\n", - "Deante 49\n", - "Deserae 49\n", - "Devean 49\n", - "Elizah 49\n", - "Emmaly 49\n", - "Emmanuela 49\n", - "Envy 49\n", - "Esli 49\n", - "Fay 49\n", - "Gurshaan 49\n", - "Hareem 49\n", - "Iven 49\n", - "Jaice 49\n", - "Jaiyana 49\n", - "Jamiracle 49\n", - "Jelissa 49\n", - "... ...\n", - "Kyndle 49\n", - "Kynsley 49\n", - "Leylanie 49\n", - "Maisha 49\n", - "Malillany 49\n", - "Mariann 49\n", - "Marquell 49\n", - "Maurilio 49\n", - "Mckynzie 49\n", - "Mehdi 49\n", - "Nabeel 49\n", - "Nalleli 49\n", - "Nassir 49\n", - "Nazier 49\n", - "Nishant 49\n", - "Rebecka 49\n", - "Reghan 49\n", - "Ridwan 49\n", - "Riot 49\n", - "Rubin 49\n", - "Ryatt 49\n", - "Sameera 49\n", - "Sanjuanita 49\n", - "Shalyn 49\n", - "Skylie 49\n", - "Sriram 49\n", - "Trinton 49\n", - "Vita 49\n", - "Yoni 49\n", - "Zuleima 49\n", + " Count\n", + "Name \n", + "Aishani 49\n", + "Alara 49\n", + "Alysse 49\n", + "Ameir 49\n", + "Anely 49\n", + "... ...\n", + "Sriram 49\n", + "Trinton 49\n", + "Vita 49\n", + "Yoni 49\n", + "Zuleima 49\n", "\n", "[66 rows x 1 columns]" ] }, - "execution_count": 10, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -910,23 +724,21 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 12. What is the standard deviation of names?" + "### Step 13. What is the standard deviation of names?" ] }, { "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, + "execution_count": 12, + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "11006.069467891111" + "11006.06946789057" ] }, - "execution_count": 11, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -939,20 +751,31 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 13. Get a summary with the mean, min, max, std and quartiles." + "### Step 14. Get a summary with the mean, min, max, std and quartiles." ] }, { "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, + "execution_count": 13, + "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "
49
Antonina49
Aveline49
Aziah49
Baily49
Caleah49
Carlota49
Cristine49
Dahlila49
Darvin49
Deante49
Deserae49
Devean49
Elizah49
Emmaly49
Emmanuela49
Envy49
Esli49
Fay49
Gurshaan49
Hareem49
Iven49
Jaice49
Jaiyana49
Jamiracle49
Jelissa49
......
Kyndle49
Kynsley49
Leylanie49
Maisha49
Malillany49
Mariann49
Marquell49
Maurilio49
Mckynzie49
Mehdi49
Nabeel49
Nalleli49
Nassir49
Nazier49
Nishant49
Rebecka49
Reghan49
Ridwan49
Riot49
Rubin49
Ryatt49
Sameera49
Sanjuanita49
Shalyn49
Skylie49
Sriram49
\n", " \n", " \n", @@ -1009,7 +832,7 @@ "max 242874.000000" ] }, - "execution_count": 12, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -1022,23 +845,36 @@ "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python [default]", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" + "pygments_lexer": "ipython3", + "version": "3.9.1" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/06_Stats/US_Baby_Names/Solutions.ipynb b/06_Stats/US_Baby_Names/Solutions.ipynb index 9acac382e..55569c62e 100644 --- a/06_Stats/US_Baby_Names/Solutions.ipynb +++ b/06_Stats/US_Baby_Names/Solutions.ipynb @@ -23,9 +23,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -46,9 +44,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -57,13 +53,15 @@ "\n", "RangeIndex: 1016395 entries, 0 to 1016394\n", "Data columns (total 7 columns):\n", - "Unnamed: 0 1016395 non-null int64\n", - "Id 1016395 non-null int64\n", - "Name 1016395 non-null object\n", - "Year 1016395 non-null int64\n", - "Gender 1016395 non-null object\n", - "State 1016395 non-null object\n", - "Count 1016395 non-null int64\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 Unnamed: 0 1016395 non-null int64 \n", + " 1 Id 1016395 non-null int64 \n", + " 2 Name 1016395 non-null object\n", + " 3 Year 1016395 non-null int64 \n", + " 4 Gender 1016395 non-null object\n", + " 5 State 1016395 non-null object\n", + " 6 Count 1016395 non-null int64 \n", "dtypes: int64(4), object(3)\n", "memory usage: 54.3+ MB\n" ] @@ -81,14 +79,25 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -238,14 +247,25 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -322,15 +342,39 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 6. Are there more male or female names in the dataset?" + "### Step 6. What year has the highest number of baby names in the dataset?" ] }, { "cell_type": "code", "execution_count": 5, - "metadata": { - "collapsed": false - }, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Count 2007\n", + "dtype: int64" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 7. Are there more male or female names in the dataset?" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, "outputs": [ { "data": { @@ -351,15 +395,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 7. Group the dataset by name and assign to names" + "### Step 8. Group the dataset by name and assign to names" ] }, { "cell_type": "code", "execution_count": 6, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -429,15 +471,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 8. How many different names exist in the dataset?" + "### Step 9. How many different names exist in the dataset?" ] }, { "cell_type": "code", "execution_count": 7, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -456,15 +496,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 9. What is the name with most occurrences?" + "### Step 10. What is the name with most occurrences?" ] }, { "cell_type": "code", "execution_count": 8, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -483,15 +521,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 10. How many different names have the least occurrences?" + "### Step 11. How many different names have the least occurrences?" ] }, { "cell_type": "code", "execution_count": 9, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -510,15 +546,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 11. What is the median name occurrence?" + "### Step 12. What is the median name occurrence?" ] }, { "cell_type": "code", "execution_count": 10, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -864,15 +898,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 12. What is the standard deviation of names?" + "### Step 13. What is the standard deviation of names?" ] }, { "cell_type": "code", "execution_count": 11, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -891,15 +923,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 13. Get a summary with the mean, min, max, std and quartiles." + "### Step 14. Get a summary with the mean, min, max, std and quartiles." ] }, { "cell_type": "code", "execution_count": 12, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -972,23 +1002,36 @@ "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python [default]", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" + "pygments_lexer": "ipython3", + "version": "3.9.1" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/06_Stats/Wind_Stats/Exercises_with_solutions.ipynb b/06_Stats/Wind_Stats/Exercises_with_solutions.ipynb index 4a7363065..d0d2b08b1 100644 --- a/06_Stats/Wind_Stats/Exercises_with_solutions.ipynb +++ b/06_Stats/Wind_Stats/Exercises_with_solutions.ipynb @@ -4,7 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Wind Statistics" + "# Wind Statistics\n", + "\n", + "Check out [Wind Statistics Exercises Video Tutorial](https://youtu.be/2x3WsWiNV18) to watch a data scientist go through the exercises" ] }, { @@ -69,7 +71,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -134,7 +136,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -150,7 +152,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -166,7 +168,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -182,7 +184,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -198,7 +200,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -295,7 +297,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -311,7 +313,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -327,7 +329,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -343,7 +345,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -359,7 +361,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -478,7 +480,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -493,7 +495,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -508,7 +510,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -523,7 +525,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -538,7 +540,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -640,7 +642,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 7, "metadata": { "scrolled": true }, @@ -663,7 +665,7 @@ "dtype: int64" ] }, - "execution_count": 10, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -687,7 +689,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -696,13 +698,15 @@ "10.227883764282167" ] }, - "execution_count": 11, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "data.sum().sum() / data.notna().sum().sum()" + "data.sum().sum() / data.notna().sum().sum()\n", + "\n", + "# data.mean().mean()" ] }, { @@ -4146,7 +4150,20 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.7.4" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, diff --git a/07_Visualization/.DS_Store b/07_Visualization/.DS_Store new file mode 100644 index 000000000..7e331a58f Binary files /dev/null and b/07_Visualization/.DS_Store differ diff --git a/07_Visualization/Chipotle/Exercise_with_Solutions.ipynb b/07_Visualization/Chipotle/Exercise_with_Solutions.ipynb index 12d9743f6..a020818f1 100644 --- a/07_Visualization/Chipotle/Exercise_with_Solutions.ipynb +++ b/07_Visualization/Chipotle/Exercise_with_Solutions.ipynb @@ -4,7 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Visualizing Chipotle's Data" + "# Visualizing Chipotle's Data\n", + "\n", + "Check out [Chipotle's Visualization Exercises Video Tutorial](https://youtu.be/BLD2mAB3kaw) to watch a data scientist go through the exercises" ] }, { @@ -67,7 +69,6 @@ "cell_type": "code", "execution_count": 134, "metadata": {}, - "outputs": [ { "data": { @@ -352,7 +353,20 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.4" + "version": "3.7.3" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, diff --git a/07_Visualization/Chipotle/Solutions.ipynb b/07_Visualization/Chipotle/Solutions.ipynb index 23e7498b3..971e2e109 100644 --- a/07_Visualization/Chipotle/Solutions.ipynb +++ b/07_Visualization/Chipotle/Solutions.ipynb @@ -50,11 +50,7 @@ "execution_count": 2, "metadata": {}, "outputs": [], - "source": [ - "url = 'https://raw.githubusercontent.com/justmarkham/DAT8/master/data/chipotle.tsv'\n", - " \n", - "chipo = pd.read_csv(url, sep = '\\t')" - ] + "source": [] }, { "cell_type": "markdown", @@ -214,9 +210,7 @@ "output_type": "execute_result" } ], - "source": [ - "chipo.head(10)" - ] + "source": [] }, { "cell_type": "markdown", @@ -243,30 +237,7 @@ "output_type": "display_data" } ], - "source": [ - "# get the Series of the names\n", - "x = chipo.item_name\n", - "\n", - "# use the Counter class from collections to create a dictionary with keys(text) and frequency\n", - "letter_counts = Counter(x)\n", - "\n", - "# convert the dictionary to a DataFrame\n", - "df = pd.DataFrame.from_dict(letter_counts, orient='index')\n", - "\n", - "# sort the values from the top to the least value and slice the first 5 items\n", - "df = df[0].sort_values(ascending = True)[45:50]\n", - "\n", - "# create the plot\n", - "df.plot(kind='bar')\n", - "\n", - "# Set the title and labels\n", - "plt.xlabel('Items')\n", - "plt.ylabel('Number of Times Ordered')\n", - "plt.title('Most ordered Chipotle\\'s Items')\n", - "\n", - "# show the plot\n", - "plt.show()" - ] + "source": [] }, { "cell_type": "markdown", @@ -304,23 +275,7 @@ "output_type": "display_data" } ], - "source": [ - "# create a list of prices\n", - "chipo.item_price = [float(value[1:-1]) for value in chipo.item_price] # strip the dollar sign and trailing space\n", - "\n", - "# then groupby the orders and sum\n", - "orders = chipo.groupby('order_id').sum()\n", - "\n", - "# creates the scatterplot\n", - "# plt.scatter(orders.quantity, orders.item_price, s = 50, c = 'green')\n", - "plt.scatter(x = orders.item_price, y = orders.quantity, s = 50, c = 'green')\n", - "\n", - "# Set the title and labels\n", - "plt.xlabel('Order Price')\n", - "plt.ylabel('Items ordered')\n", - "plt.title('Number of items ordered per order price')\n", - "plt.ylim(0)" - ] + "source": [] }, { "cell_type": "markdown", @@ -353,9 +308,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.8" + "version": "3.9.1" } }, "nbformat": 4, "nbformat_minor": 1 -} \ No newline at end of file +} diff --git a/07_Visualization/Tips/Exercises_with_code_and_solutions.ipynb b/07_Visualization/Tips/Exercises_with_code_and_solutions.ipynb index 3418dc4e7..b78b0f582 100644 --- a/07_Visualization/Tips/Exercises_with_code_and_solutions.ipynb +++ b/07_Visualization/Tips/Exercises_with_code_and_solutions.ipynb @@ -4,7 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Tips" + "# Tips\n", + "\n", + "Check out [Tips Visualization Exercises Video Tutorial](https://youtu.be/oiuKFigW4YM) to watch a data scientist go through the exercises" ] }, { @@ -547,7 +549,20 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.7.3" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, diff --git a/07_Visualization/Titanic_Desaster/Exercises.ipynb b/07_Visualization/Titanic_Disaster/Exercises.ipynb similarity index 100% rename from 07_Visualization/Titanic_Desaster/Exercises.ipynb rename to 07_Visualization/Titanic_Disaster/Exercises.ipynb diff --git a/07_Visualization/Titanic_Desaster/Exercises_code_with_solutions.ipynb b/07_Visualization/Titanic_Disaster/Exercises_code_with_solutions.ipynb similarity index 99% rename from 07_Visualization/Titanic_Desaster/Exercises_code_with_solutions.ipynb rename to 07_Visualization/Titanic_Disaster/Exercises_code_with_solutions.ipynb index 2d438d85a..ee7a4619c 100644 --- a/07_Visualization/Titanic_Desaster/Exercises_code_with_solutions.ipynb +++ b/07_Visualization/Titanic_Disaster/Exercises_code_with_solutions.ipynb @@ -4,7 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Visualizing the Titanic Disaster" + "# Visualizing the Titanic Disaster\n", + "\n", + "Check out [Titanic Visualization Exercises Video Tutorial](https://youtu.be/CBT0buoF_Ns) to watch a data scientist go through the exercises" ] }, { @@ -550,21 +552,34 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.16" + "pygments_lexer": "ipython3", + "version": "3.7.3" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, diff --git a/07_Visualization/Titanic_Desaster/Solutions.ipynb b/07_Visualization/Titanic_Disaster/Solutions.ipynb similarity index 100% rename from 07_Visualization/Titanic_Desaster/Solutions.ipynb rename to 07_Visualization/Titanic_Disaster/Solutions.ipynb diff --git a/07_Visualization/Titanic_Desaster/train.csv b/07_Visualization/Titanic_Disaster/train.csv similarity index 100% rename from 07_Visualization/Titanic_Desaster/train.csv rename to 07_Visualization/Titanic_Disaster/train.csv diff --git a/09_Time_Series/.DS_Store b/09_Time_Series/.DS_Store new file mode 100644 index 000000000..45c3ca1f8 Binary files /dev/null and b/09_Time_Series/.DS_Store differ diff --git a/09_Time_Series/Apple_Stock/Exercises-with-solutions-code.ipynb b/09_Time_Series/Apple_Stock/Exercises-with-solutions-code.ipynb index 6191320fd..e2bbb9b0a 100644 --- a/09_Time_Series/Apple_Stock/Exercises-with-solutions-code.ipynb +++ b/09_Time_Series/Apple_Stock/Exercises-with-solutions-code.ipynb @@ -4,7 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Apple Stock" + "# Apple Stock\n", + "\n", + "Check out [Apple Stock Exercises Video Tutorial](https://youtu.be/wpXkR_IZcug) to watch a data scientist go through the exercises" ] }, { @@ -22,9 +24,7 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", @@ -53,9 +53,7 @@ { "cell_type": "code", "execution_count": 32, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -160,9 +158,7 @@ { "cell_type": "code", "execution_count": 33, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -196,9 +192,7 @@ { "cell_type": "code", "execution_count": 34, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -232,9 +226,7 @@ { "cell_type": "code", "execution_count": 35, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -342,9 +334,7 @@ { "cell_type": "code", "execution_count": 36, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -372,9 +362,7 @@ { "cell_type": "code", "execution_count": 39, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -480,9 +468,7 @@ { "cell_type": "code", "execution_count": 48, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -590,9 +576,7 @@ { "cell_type": "code", "execution_count": 65, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -619,9 +603,7 @@ { "cell_type": "code", "execution_count": 66, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -650,9 +632,7 @@ { "cell_type": "code", "execution_count": 81, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -694,23 +674,36 @@ "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python [default]", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" + "pygments_lexer": "ipython3", + "version": "3.7.3" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/09_Time_Series/Getting_Financial_Data/Exercises.ipynb b/09_Time_Series/Getting_Financial_Data/Exercises.ipynb index aafa0b4b4..2cf792c43 100644 --- a/09_Time_Series/Getting_Financial_Data/Exercises.ipynb +++ b/09_Time_Series/Getting_Financial_Data/Exercises.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Getting Financial Data - Google Finance" + "# Getting Financial Data - Pandas Datareader" ] }, { @@ -22,9 +22,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -32,15 +30,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 2. Create your time range (start and end variables). The start date should be 01/01/2015 and the end should today (whatever your today is)" + "### Step 2. Create your time range (start and end variables). The start date should be 01/01/2015 and the end should today (whatever your today is)." ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -48,15 +44,24 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 3. Select the Apple, Tesla, Twitter, IBM, LinkedIn stocks symbols and assign them to a variable called stocks" + "### Step 3. Get an API key for one of the APIs that are supported by Pandas Datareader, preferably for AlphaVantage.\n", + "\n", + "If you do not have an API key for any of the supported APIs, it is easiest to get one for [AlphaVantage](https://www.alphavantage.co/support/#api-key). (Note that the API key is shown directly after the signup. You do *not* receive it via e-mail.)\n", + "\n", + "(For a full list of the APIs that are supported by Pandas Datareader, [see here](https://pydata.github.io/pandas-datareader/readers/index.html). As the APIs are provided by third parties, this list may change.)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 4. Use Pandas Datarader to read the daily time series for the Apple stock (ticker symbol AAPL) between 01/01/2015 and today, assign it to df_apple and print it." ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -64,15 +69,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 4. Read the data from google, assign to df and print it" + "### Step 5. Add a new column \"stock\" to the dataframe and add the ticker symbol" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -80,15 +83,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 5. What is the type of structure of df ?" + "### Step 6. Repeat the two previous steps for a few other stocks, always creating a new dataframe: Tesla, IBM and Microsoft. (Ticker symbols TSLA, IBM and MSFT.)" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -96,16 +97,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 6. Print all the Items axis values\n", - "#### To learn more about the Panel structure go to [documentation](http://pandas.pydata.org/pandas-docs/stable/dsintro.html#panel) " + "### Step 7. Combine the four separate dataFrames into one combined dataFrame df that holds the information for all four stocks" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -113,15 +111,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 7. Good, now we know the data avaiable. Create a dataFrame called vol, with the Volume values." + "### Step 8. Shift the stock column into the index (making it a multi-level index consisting of the ticker symbol and the date)." ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -129,17 +125,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 8. Aggregate the data of Volume to weekly\n", - "#### Hint: Be careful to not sum data from the same week of 2015 and other years." + "### Step 7. Create a dataFrame called vol, with the volume values." ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false, - "scrolled": true - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -147,15 +139,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 9. Find all the volume traded in the year of 2015" + "### Step 8. Aggregate the data of volume to weekly.\n", + "Hint: Be careful to not sum data from the same week of 2015 and other years." ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [] }, @@ -163,38 +154,36 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### BONUS: Create your own question and answer it." + "### Step 9. Find all the volume traded in the year of 2015" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" + "pygments_lexer": "ipython3", + "version": "3.7.4" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/09_Time_Series/Getting_Financial_Data/Exercises_solutions.ipynb b/09_Time_Series/Getting_Financial_Data/Exercises_solutions.ipynb new file mode 100644 index 000000000..7880b7e3d --- /dev/null +++ b/09_Time_Series/Getting_Financial_Data/Exercises_solutions.ipynb @@ -0,0 +1,1194 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Getting Financial Data - Pandas Datareader" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Introduction:\n", + "\n", + "This time you will get data from a website.\n", + "\n", + "\n", + "### Step 1. Import the necessary libraries" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import pandas as pd\n", + "\n", + "# package to extract data from various Internet sources into a DataFrame\n", + "# make sure you have it installed\n", + "import pandas_datareader.data as web\n", + "\n", + "# package for dates\n", + "import datetime as dt" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 2. Create your time range (start and end variables). The start date should be 01/01/2015 and the end should today (whatever your today is)." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "datetime.datetime(2015, 1, 1, 0, 0)" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "start_dt = dt.datetime(2015, 1, 1, 0, 0)\n", + "start_dt" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 3. Get an API key for one of the APIs that are supported by Pandas Datareader, preferably for AlphaVantage.\n", + "\n", + "If you do not have an API key for any of the supported APIs, it is easiest to get one for [AlphaVantage](https://www.alphavantage.co/support/#api-key). (Note that the API key is shown directly after the signup. You do *not* receive it via e-mail.)\n", + "\n", + "(For a full list of the APIs that are supported by Pandas Datareader, [see here](https://pydata.github.io/pandas-datareader/readers/index.html). As the APIs are provided by third parties, this list may change.)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 4. Use Pandas Datarader to read the daily time series for the Apple stock (ticker symbol AAPL) between 01/01/2015 and today, assign it to df_apple and print it." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "
002061-01-0115.0414.9615.04
112061-01-0214.71NaN13.83
222061-01-0318.5016.8812.71
332061-01-0410.586.6310.88
442061-01-0513.3313.25
001961-01-0115.0414.9615.04
111961-01-0214.71NaN13.83
221961-01-0318.5016.8812.71
331961-01-0410.586.6310.88
441961-01-0513.3313.25
1961-01-011961-01-0115.0414.9613.1715.04
1961-01-021961-01-0214.71NaN10.8313.83
1961-01-031961-01-0318.5016.8812.3312.71
1961-01-041961-01-0410.586.6311.7510.88
1961-01-051961-01-0513.3313.2511.42
\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", + "
openhighlowclosevolume
2015-01-02111.390111.440107.3500109.3353204626
2015-01-05108.290108.650105.4100106.2564285491
2015-01-06106.540107.430104.6300106.2665797116
2015-01-07107.200108.200106.6950107.7540105934
2015-01-08109.230112.150108.7000111.8959364547
..................
2021-11-15150.370151.880149.4300150.0059222803
2021-11-16149.940151.488149.3400151.0059256210
2021-11-17150.995155.000150.9900153.4988807000
2021-11-18153.710158.670153.0500157.87137827673
2021-11-19157.650161.020156.5328160.55116744360
\n", + "

1735 rows × 5 columns

\n", + "
" + ], + "text/plain": [ + " open high low close volume\n", + "2015-01-02 111.390 111.440 107.3500 109.33 53204626\n", + "2015-01-05 108.290 108.650 105.4100 106.25 64285491\n", + "2015-01-06 106.540 107.430 104.6300 106.26 65797116\n", + "2015-01-07 107.200 108.200 106.6950 107.75 40105934\n", + "2015-01-08 109.230 112.150 108.7000 111.89 59364547\n", + "... ... ... ... ... ...\n", + "2021-11-15 150.370 151.880 149.4300 150.00 59222803\n", + "2021-11-16 149.940 151.488 149.3400 151.00 59256210\n", + "2021-11-17 150.995 155.000 150.9900 153.49 88807000\n", + "2021-11-18 153.710 158.670 153.0500 157.87 137827673\n", + "2021-11-19 157.650 161.020 156.5328 160.55 116744360\n", + "\n", + "[1735 rows x 5 columns]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_apple = web.DataReader(\"AAPL\", \"av-daily\", start=start_dt, api_key=\"AZOBAQ2SK8AC1MUD\")\n", + "df_apple\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 5. Add a new column \"stock\" to the dataframe and add the ticker symbol" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "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", + "
openhighlowclosevolumestock
2015-01-02111.390111.440107.3500109.3353204626AAPL
2015-01-05108.290108.650105.4100106.2564285491AAPL
2015-01-06106.540107.430104.6300106.2665797116AAPL
2015-01-07107.200108.200106.6950107.7540105934AAPL
2015-01-08109.230112.150108.7000111.8959364547AAPL
.....................
2021-11-15150.370151.880149.4300150.0059222803AAPL
2021-11-16149.940151.488149.3400151.0059256210AAPL
2021-11-17150.995155.000150.9900153.4988807000AAPL
2021-11-18153.710158.670153.0500157.87137827673AAPL
2021-11-19157.650161.020156.5328160.55116744360AAPL
\n", + "

1735 rows × 6 columns

\n", + "
" + ], + "text/plain": [ + " open high low close volume stock\n", + "2015-01-02 111.390 111.440 107.3500 109.33 53204626 AAPL\n", + "2015-01-05 108.290 108.650 105.4100 106.25 64285491 AAPL\n", + "2015-01-06 106.540 107.430 104.6300 106.26 65797116 AAPL\n", + "2015-01-07 107.200 108.200 106.6950 107.75 40105934 AAPL\n", + "2015-01-08 109.230 112.150 108.7000 111.89 59364547 AAPL\n", + "... ... ... ... ... ... ...\n", + "2021-11-15 150.370 151.880 149.4300 150.00 59222803 AAPL\n", + "2021-11-16 149.940 151.488 149.3400 151.00 59256210 AAPL\n", + "2021-11-17 150.995 155.000 150.9900 153.49 88807000 AAPL\n", + "2021-11-18 153.710 158.670 153.0500 157.87 137827673 AAPL\n", + "2021-11-19 157.650 161.020 156.5328 160.55 116744360 AAPL\n", + "\n", + "[1735 rows x 6 columns]" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_apple['stock'] = 'AAPL'\n", + "df_apple" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 6. Repeat the two previous steps for a few other stocks, always creating a new dataframe: Tesla, IBM and Microsoft. (Ticker symbols TSLA, IBM and MSFT.)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "df_tesla = web.DataReader(\"TSLA\", \"av-daily\", start=start_dt, api_key=\"AZOBAQ2SK8AC1MUD\")\n", + "df_tesla['stock'] = \"TSLA\"\n", + "\n", + "df_ibm = web.DataReader(\"IBM\", \"av-daily\", start=start_dt, api_key=\"AZOBAQ2SK8AC1MUD\")\n", + "df_ibm['stock'] = \"IBM\"\n", + "\n", + "df_microsoft = web.DataReader(\"MSFT\", \"av-daily\", start=start_dt, api_key=\"AZOBAQ2SK8AC1MUD\")\n", + "df_microsoft['stock'] = \"MSFT\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 7. Combine the four separate dataFrames into one combined dataFrame df that holds the information for all four stocks" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "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", + "
openhighlowclosevolumestock
2015-01-02111.39111.44107.350109.3353204626AAPL
2015-01-05108.29108.65105.410106.2564285491AAPL
2015-01-06106.54107.43104.630106.2665797116AAPL
2015-01-07107.20108.20106.695107.7540105934AAPL
2015-01-08109.23112.15108.700111.8959364547AAPL
.....................
2021-11-15337.54337.88334.034336.0716723009MSFT
2021-11-16335.68340.67335.510339.5120886832MSFT
2021-11-17338.94342.19338.000339.1219053380MSFT
2021-11-18338.18342.45337.120341.2722463533MSFT
2021-11-19342.64345.10342.200343.1121095274MSFT
\n", + "

6940 rows × 6 columns

\n", + "
" + ], + "text/plain": [ + " open high low close volume stock\n", + "2015-01-02 111.39 111.44 107.350 109.33 53204626 AAPL\n", + "2015-01-05 108.29 108.65 105.410 106.25 64285491 AAPL\n", + "2015-01-06 106.54 107.43 104.630 106.26 65797116 AAPL\n", + "2015-01-07 107.20 108.20 106.695 107.75 40105934 AAPL\n", + "2015-01-08 109.23 112.15 108.700 111.89 59364547 AAPL\n", + "... ... ... ... ... ... ...\n", + "2021-11-15 337.54 337.88 334.034 336.07 16723009 MSFT\n", + "2021-11-16 335.68 340.67 335.510 339.51 20886832 MSFT\n", + "2021-11-17 338.94 342.19 338.000 339.12 19053380 MSFT\n", + "2021-11-18 338.18 342.45 337.120 341.27 22463533 MSFT\n", + "2021-11-19 342.64 345.10 342.200 343.11 21095274 MSFT\n", + "\n", + "[6940 rows x 6 columns]" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_all = pd.concat([df_apple, df_tesla, df_ibm, df_microsoft])\n", + "df_all" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 8. Shift the stock column into the index (making it a multi-level index consisting of the ticker symbol and the date)." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "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", + "
openhighlowclosevolume
stock
2015-01-02AAPL111.39111.44107.350109.3353204626
2015-01-05AAPL108.29108.65105.410106.2564285491
2015-01-06AAPL106.54107.43104.630106.2665797116
2015-01-07AAPL107.20108.20106.695107.7540105934
2015-01-08AAPL109.23112.15108.700111.8959364547
.....................
2021-11-15MSFT337.54337.88334.034336.0716723009
2021-11-16MSFT335.68340.67335.510339.5120886832
2021-11-17MSFT338.94342.19338.000339.1219053380
2021-11-18MSFT338.18342.45337.120341.2722463533
2021-11-19MSFT342.64345.10342.200343.1121095274
\n", + "

6940 rows × 5 columns

\n", + "
" + ], + "text/plain": [ + " open high low close volume\n", + " stock \n", + "2015-01-02 AAPL 111.39 111.44 107.350 109.33 53204626\n", + "2015-01-05 AAPL 108.29 108.65 105.410 106.25 64285491\n", + "2015-01-06 AAPL 106.54 107.43 104.630 106.26 65797116\n", + "2015-01-07 AAPL 107.20 108.20 106.695 107.75 40105934\n", + "2015-01-08 AAPL 109.23 112.15 108.700 111.89 59364547\n", + "... ... ... ... ... ...\n", + "2021-11-15 MSFT 337.54 337.88 334.034 336.07 16723009\n", + "2021-11-16 MSFT 335.68 340.67 335.510 339.51 20886832\n", + "2021-11-17 MSFT 338.94 342.19 338.000 339.12 19053380\n", + "2021-11-18 MSFT 338.18 342.45 337.120 341.27 22463533\n", + "2021-11-19 MSFT 342.64 345.10 342.200 343.11 21095274\n", + "\n", + "[6940 rows x 5 columns]" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_all = df_all.set_index('stock', append=True)\n", + "df_all" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 7. Create a dataFrame called vol, with the volume values." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "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", + "
volume
stock
2015-01-02AAPL53204626
2015-01-05AAPL64285491
2015-01-06AAPL65797116
2015-01-07AAPL40105934
2015-01-08AAPL59364547
.........
2021-11-15MSFT16723009
2021-11-16MSFT20886832
2021-11-17MSFT19053380
2021-11-18MSFT22463533
2021-11-19MSFT21095274
\n", + "

6940 rows × 1 columns

\n", + "
" + ], + "text/plain": [ + " volume\n", + " stock \n", + "2015-01-02 AAPL 53204626\n", + "2015-01-05 AAPL 64285491\n", + "2015-01-06 AAPL 65797116\n", + "2015-01-07 AAPL 40105934\n", + "2015-01-08 AAPL 59364547\n", + "... ...\n", + "2021-11-15 MSFT 16723009\n", + "2021-11-16 MSFT 20886832\n", + "2021-11-17 MSFT 19053380\n", + "2021-11-18 MSFT 22463533\n", + "2021-11-19 MSFT 21095274\n", + "\n", + "[6940 rows x 1 columns]" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vol = df_all.filter(['volume'])\n", + "vol" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 8. Aggregate the data of volume to weekly.\n", + "Hint: Be careful to not sum data from the same week of 2015 and other years." + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "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", + "
stockAAPLIBMMSFTTSLA
yearweek
20151532046265525341279138524764443
22828681872444036015859662422622034
33042266472327205615708813630799137
41987370413123079713735263216215501
54658426843292730743778677815720217
..................
2021423406912905973158291315937109982713
4339273993634288134159314433220925116
4432268895829791780120621826178974628
4528102655629109912106622220182318404
4646185804624205817100222028134998459
\n", + "

360 rows × 4 columns

\n", + "
" + ], + "text/plain": [ + "stock AAPL IBM MSFT TSLA\n", + "year week \n", + "2015 1 53204626 5525341 27913852 4764443\n", + " 2 282868187 24440360 158596624 22622034\n", + " 3 304226647 23272056 157088136 30799137\n", + " 4 198737041 31230797 137352632 16215501\n", + " 5 465842684 32927307 437786778 15720217\n", + "... ... ... ... ...\n", + "2021 42 340691290 59731582 91315937 109982713\n", + " 43 392739936 34288134 159314433 220925116\n", + " 44 322688958 29791780 120621826 178974628\n", + " 45 281026556 29109912 106622220 182318404\n", + " 46 461858046 24205817 100222028 134998459\n", + "\n", + "[360 rows x 4 columns]" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vol_week = vol.rename_axis(index=['dt', 'stock'])\n", + "vol_week.reset_index(inplace=True)\n", + "vol_week.dt = pd.to_datetime(vol_week.dt)\n", + "vol_week['year'] = vol_week['dt'].map(lambda x: x.year)\n", + "vol_week['week'] = vol_week['dt'].map(lambda x: x.week)\n", + "vol_week.pop('dt')\n", + "\n", + "vol_week.set_index(['year', 'week', 'stock'], inplace=True)\n", + "vol_week = vol_week.groupby([pd.Grouper(level='stock'), pd.Grouper(level='year'), pd.Grouper(level='week')]).sum()\n", + "\n", + "vol_week = vol_week.reset_index()\n", + "vol_week = vol_week.pivot(index=['year', 'week'], columns='stock')\n", + "vol_week.columns.droplevel(0)\n", + "vol_week.columns = vol_week.columns.droplevel(0)\n", + "vol_week" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 9. Find all the volume traded in the year of 2015" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "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", + "
stockAAPLIBMMSFTTSLA
year
201513064316775110554552190575823111086708380
\n", + "
" + ], + "text/plain": [ + "stock AAPL IBM MSFT TSLA\n", + "year \n", + "2015 13064316775 1105545521 9057582311 1086708380" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vol_year = vol_week.groupby('year').sum()\n", + "vol_year.loc[2015:2015]" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.9.5" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/09_Time_Series/Getting_Financial_Data/Exercises_with_solutions_and_code.ipynb b/09_Time_Series/Getting_Financial_Data/Exercises_with_solutions_and_code.ipynb index 2cdbb206a..3d7ae709a 100644 --- a/09_Time_Series/Getting_Financial_Data/Exercises_with_solutions_and_code.ipynb +++ b/09_Time_Series/Getting_Financial_Data/Exercises_with_solutions_and_code.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Getting Financial Data - Google Finance" + "# Getting Financial Data - Pandas Datareader" ] }, { @@ -21,17 +21,16 @@ }, { "cell_type": "code", - "execution_count": 30, - "metadata": { - "collapsed": false - }, + "execution_count": 1, + "metadata": {}, "outputs": [], "source": [ + "import numpy as np\n", "import pandas as pd\n", "\n", "# package to extract data from various Internet sources into a DataFrame\n", "# make sure you have it installed\n", - "from pandas_datareader import data, wb\n", + "import pandas_datareader.data as web\n", "\n", "# package for dates\n", "import datetime as dt" @@ -41,15 +40,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 2. Create your time range (start and end variables). The start date should be 01/01/2015 and the end should today (whatever your today is)" + "### Step 2. Create your time range (start and end variables). The start date should be 01/01/2015 and the end should today (whatever your today is)." ] }, { "cell_type": "code", - "execution_count": 75, - "metadata": { - "collapsed": false - }, + "execution_count": 2, + "metadata": {}, "outputs": [ { "data": { @@ -57,14 +54,13 @@ "datetime.datetime(2015, 1, 1, 0, 0)" ] }, - "execution_count": 75, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "start = dt.datetime(2015, 1, 1)\n", - "\n", "end = dt.datetime.today()\n", "\n", "start" @@ -74,131 +70,612 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 3. Select the Apple, Tesla, Twitter, IBM, LinkedIn stocks symbols and assign them to a variable called stocks" + "### Step 3. Get an API key for one of the APIs that are supported by Pandas Datareader, preferably for AlphaVantage.\n", + "\n", + "If you do not have an API key for any of the supported APIs, it is easiest to get one for [AlphaVantage](https://www.alphavantage.co/support/#api-key). (Note that the API key is shown directly after the signup. You do *not* receive it via e-mail.)\n", + "\n", + "(For a full list of the APIs that are supported by Pandas Datareader, [see here](https://pydata.github.io/pandas-datareader/readers/index.html). As the APIs are provided by third parties, this list may change.)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 4. Use Pandas Datarader to read the daily time series for the Apple stock (ticker symbol AAPL) between 01/01/2015 and today, assign it to df_apple and print it." ] }, { "cell_type": "code", - "execution_count": 76, - "metadata": { - "collapsed": false - }, - "outputs": [], + "execution_count": 3, + "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", + "
openhighlowclosevolume
2015-01-02111.3900111.4400107.350109.3353204626
2015-01-05108.2900108.6500105.410106.2564285491
2015-01-06106.5400107.4300104.630106.2665797116
2015-01-07107.2000108.2000106.695107.7540105934
2015-01-08109.2300112.1500108.700111.8959364547
..................
2020-08-24514.7900515.1400495.745503.4386484442
2020-08-25498.7900500.7172492.210499.3052873947
2020-08-26504.7165507.9700500.330506.0940755567
2020-08-27508.5700509.9400495.330500.0438888096
2020-08-28504.0500505.7700498.310499.2346907479
\n", + "

1425 rows × 5 columns

\n", + "
" + ], + "text/plain": [ + " open high low close volume\n", + "2015-01-02 111.3900 111.4400 107.350 109.33 53204626\n", + "2015-01-05 108.2900 108.6500 105.410 106.25 64285491\n", + "2015-01-06 106.5400 107.4300 104.630 106.26 65797116\n", + "2015-01-07 107.2000 108.2000 106.695 107.75 40105934\n", + "2015-01-08 109.2300 112.1500 108.700 111.89 59364547\n", + "... ... ... ... ... ...\n", + "2020-08-24 514.7900 515.1400 495.745 503.43 86484442\n", + "2020-08-25 498.7900 500.7172 492.210 499.30 52873947\n", + "2020-08-26 504.7165 507.9700 500.330 506.09 40755567\n", + "2020-08-27 508.5700 509.9400 495.330 500.04 38888096\n", + "2020-08-28 504.0500 505.7700 498.310 499.23 46907479\n", + "\n", + "[1425 rows x 5 columns]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "stocks = ['AAPL', 'TSLA', 'IBM', 'LNKD']" + "df_apple = web.DataReader(name=\"AAPL\",\n", + " data_source=\"av-daily\",\n", + " start=start,\n", + " end=end,\n", + " api_key=\"your_alpha_vantage_api_key_goes_here\")\n", + "\n", + "df_apple" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 4. Read the data from google, assign to df and print it" + "### Step 5. Add a new column \"stock\" to the dataframe and add the ticker symbol" ] }, { "cell_type": "code", - "execution_count": 77, - "metadata": { - "collapsed": false - }, + "execution_count": 4, + "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", + "
openhighlowclosevolumestock
2015-01-02111.3900111.4400107.350109.3353204626AAPL
2015-01-05108.2900108.6500105.410106.2564285491AAPL
2015-01-06106.5400107.4300104.630106.2665797116AAPL
2015-01-07107.2000108.2000106.695107.7540105934AAPL
2015-01-08109.2300112.1500108.700111.8959364547AAPL
.....................
2020-08-24514.7900515.1400495.745503.4386484442AAPL
2020-08-25498.7900500.7172492.210499.3052873947AAPL
2020-08-26504.7165507.9700500.330506.0940755567AAPL
2020-08-27508.5700509.9400495.330500.0438888096AAPL
2020-08-28504.0500505.7700498.310499.2346907479AAPL
\n", + "

1425 rows × 6 columns

\n", + "
" + ], "text/plain": [ - "\n", - "Dimensions: 5 (items) x 399 (major_axis) x 4 (minor_axis)\n", - "Items axis: Open to Volume\n", - "Major_axis axis: 2015-01-02 00:00:00 to 2016-08-02 00:00:00\n", - "Minor_axis axis: AAPL to TSLA" + " open high low close volume stock\n", + "2015-01-02 111.3900 111.4400 107.350 109.33 53204626 AAPL\n", + "2015-01-05 108.2900 108.6500 105.410 106.25 64285491 AAPL\n", + "2015-01-06 106.5400 107.4300 104.630 106.26 65797116 AAPL\n", + "2015-01-07 107.2000 108.2000 106.695 107.75 40105934 AAPL\n", + "2015-01-08 109.2300 112.1500 108.700 111.89 59364547 AAPL\n", + "... ... ... ... ... ... ...\n", + "2020-08-24 514.7900 515.1400 495.745 503.43 86484442 AAPL\n", + "2020-08-25 498.7900 500.7172 492.210 499.30 52873947 AAPL\n", + "2020-08-26 504.7165 507.9700 500.330 506.09 40755567 AAPL\n", + "2020-08-27 508.5700 509.9400 495.330 500.04 38888096 AAPL\n", + "2020-08-28 504.0500 505.7700 498.310 499.23 46907479 AAPL\n", + "\n", + "[1425 rows x 6 columns]" ] }, - "execution_count": 77, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "df = web.DataReader(stocks, 'google', start, end)\n", - "df" + "df_apple[\"stock\"] = \"AAPL\"\n", + "df_apple" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 5. What is the type of structure of df ?" + "### Step 6. Repeat the two previous steps for a few other stocks, always creating a new dataframe: Tesla, IBM and Microsoft. (Ticker symbols TSLA, IBM and MSFT.)" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, + "execution_count": 5, + "metadata": {}, "outputs": [], "source": [ - "# 'pandas.core.panel.Panel'" + "# Tesla\n", + "df_tesla = web.DataReader(name=\"TSLA\",\n", + " data_source=\"av-daily\",\n", + " start=start,\n", + " end=end,\n", + " api_key=\"your_alpha_vantage_api_key_goes_here\")\n", + "\n", + "df_tesla[\"stock\"] = \"TSLA\"\n", + "\n", + "# IBM\n", + "df_ibm = web.DataReader(name=\"IBM\",\n", + " data_source=\"av-daily\",\n", + " start=start,\n", + " end=end,\n", + " api_key=\"your_alpha_vantage_api_key_goes_here\")\n", + "\n", + "df_ibm[\"stock\"] = \"IBM\"\n", + "\n", + "# Microsoft\n", + "df_microsoft = web.DataReader(name=\"MSFT\",\n", + " data_source=\"av-daily\",\n", + " start=start,\n", + " end=end,\n", + " api_key=\"your_alpha_vantage_api_key_goes_here\")\n", + "\n", + "df_microsoft[\"stock\"] = \"MSFT\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 6. Print all the Items axis values\n", - "#### To learn more about the Panel structure go to [documentation](http://pandas.pydata.org/pandas-docs/stable/dsintro.html#panel) " + "### Step 7. Combine the four separate dataFrames into one combined dataFrame df that holds the information for all four stocks" ] }, { "cell_type": "code", - "execution_count": 120, - "metadata": { - "collapsed": false - }, + "execution_count": 6, + "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", + "
openhighlowclosevolumestock
2015-01-02111.39111.440107.350109.3353204626AAPL
2015-01-05108.29108.650105.410106.2564285491AAPL
2015-01-06106.54107.430104.630106.2665797116AAPL
2015-01-07107.20108.200106.695107.7540105934AAPL
2015-01-08109.23112.150108.700111.8959364547AAPL
.....................
2020-08-24214.79215.520212.430213.6925460147MSFT
2020-08-25213.10216.610213.100216.4723043696MSFT
2020-08-26217.88222.090217.360221.1539600828MSFT
2020-08-27222.89231.150219.400226.5857602195MSFT
2020-08-28228.18230.644226.580228.9126292896MSFT
\n", + "

5700 rows × 6 columns

\n", + "
" + ], "text/plain": [ - "Index([u'Open', u'High', u'Low', u'Close', u'Volume'], dtype='object')" + " open high low close volume stock\n", + "2015-01-02 111.39 111.440 107.350 109.33 53204626 AAPL\n", + "2015-01-05 108.29 108.650 105.410 106.25 64285491 AAPL\n", + "2015-01-06 106.54 107.430 104.630 106.26 65797116 AAPL\n", + "2015-01-07 107.20 108.200 106.695 107.75 40105934 AAPL\n", + "2015-01-08 109.23 112.150 108.700 111.89 59364547 AAPL\n", + "... ... ... ... ... ... ...\n", + "2020-08-24 214.79 215.520 212.430 213.69 25460147 MSFT\n", + "2020-08-25 213.10 216.610 213.100 216.47 23043696 MSFT\n", + "2020-08-26 217.88 222.090 217.360 221.15 39600828 MSFT\n", + "2020-08-27 222.89 231.150 219.400 226.58 57602195 MSFT\n", + "2020-08-28 228.18 230.644 226.580 228.91 26292896 MSFT\n", + "\n", + "[5700 rows x 6 columns]" ] }, - "execution_count": 120, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "df.items" + "frames = [df_apple, df_tesla, df_ibm, df_microsoft]\n", + "\n", + "df = pd.concat(frames)\n", + "df" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 7. Good, now we know the data avaiable. Create a dataFrame called vol, with the Volume values." + "### Step 8. Shift the stock column into the index (making it a multi-level index consisting of the ticker symbol and the date)." ] }, { "cell_type": "code", - "execution_count": 122, - "metadata": { - "collapsed": false - }, + "execution_count": 7, + "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", @@ -208,197 +685,311 @@ " \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", "
AAPLIBMLNKDTSLAopenhighlowclosevolume
Datestock
2015-01-0253204626.05525466.01203743.04764443.0AAPL111.39111.440107.350109.3353204626
2015-01-0564285491.04880389.01400562.05368477.0AAPL108.29108.650105.410106.2564285491
2015-01-0665797116.06146712.02006546.06261936.0AAPL106.54107.430104.630106.2665797116
2015-01-0740105934.04701839.0985016.02968390.0AAPL107.20108.200106.695107.7540105934
2015-01-0859364547.04241113.01293955.03442509.0AAPL109.23112.150108.700111.8959364547
.....................
2020-08-24MSFT214.79215.520212.430213.6925460147
2020-08-25MSFT213.10216.610213.100216.4723043696
2020-08-26MSFT217.88222.090217.360221.1539600828
2020-08-27MSFT222.89231.150219.400226.5857602195
2020-08-28MSFT228.18230.644226.580228.9126292896
\n", + "

5700 rows × 5 columns

\n", "
" ], "text/plain": [ - " AAPL IBM LNKD TSLA\n", - "Date \n", - "2015-01-02 53204626.0 5525466.0 1203743.0 4764443.0\n", - "2015-01-05 64285491.0 4880389.0 1400562.0 5368477.0\n", - "2015-01-06 65797116.0 6146712.0 2006546.0 6261936.0\n", - "2015-01-07 40105934.0 4701839.0 985016.0 2968390.0\n", - "2015-01-08 59364547.0 4241113.0 1293955.0 3442509.0" + " open high low close volume\n", + " stock \n", + "2015-01-02 AAPL 111.39 111.440 107.350 109.33 53204626\n", + "2015-01-05 AAPL 108.29 108.650 105.410 106.25 64285491\n", + "2015-01-06 AAPL 106.54 107.430 104.630 106.26 65797116\n", + "2015-01-07 AAPL 107.20 108.200 106.695 107.75 40105934\n", + "2015-01-08 AAPL 109.23 112.150 108.700 111.89 59364547\n", + "... ... ... ... ... ...\n", + "2020-08-24 MSFT 214.79 215.520 212.430 213.69 25460147\n", + "2020-08-25 MSFT 213.10 216.610 213.100 216.47 23043696\n", + "2020-08-26 MSFT 217.88 222.090 217.360 221.15 39600828\n", + "2020-08-27 MSFT 222.89 231.150 219.400 226.58 57602195\n", + "2020-08-28 MSFT 228.18 230.644 226.580 228.91 26292896\n", + "\n", + "[5700 rows x 5 columns]" ] }, - "execution_count": 122, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "vol = df['Volume']\n", - "vol.head()" + "df.set_index(keys=\"stock\", append=True, inplace=True)\n", + "df" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 8. Aggregate the data of Volume to weekly\n", - "#### Hint: Be careful to not sum data from the same week of 2015 and other years." + "### Step 7. Create a dataFrame called vol, with the volume values." ] }, { "cell_type": "code", - "execution_count": 132, - "metadata": { - "collapsed": false, - "scrolled": true - }, + "execution_count": 8, + "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", "
AAPLIBMLNKDTSLAvolume
weekyearstock
1201553204626.05525466.01203743.04764443.02015-01-02AAPL53204626
2015-01-05AAPL64285491
2016343422014.025233098.06630485.020967926.02015-01-06AAPL65797116
22015283252615.024458400.07203125.022709607.02015-01-07AAPL40105934
2015-01-08AAPL59364547
2016302072797.029379214.09160521.022997290.0.........
32015304226647.023263206.07084168.030799137.02020-08-24MSFT25460147
2020-08-25MSFT23043696
2020-08-26MSFT39600828
2020-08-27MSFT57602195
2020-08-28MSFT26292896
\n", + "

5700 rows × 1 columns

\n", "
" ], "text/plain": [ - " AAPL IBM LNKD TSLA\n", - "week year \n", - "1 2015 53204626.0 5525466.0 1203743.0 4764443.0\n", - " 2016 343422014.0 25233098.0 6630485.0 20967926.0\n", - "2 2015 283252615.0 24458400.0 7203125.0 22709607.0\n", - " 2016 302072797.0 29379214.0 9160521.0 22997290.0\n", - "3 2015 304226647.0 23263206.0 7084168.0 30799137.0" + " volume\n", + " stock \n", + "2015-01-02 AAPL 53204626\n", + "2015-01-05 AAPL 64285491\n", + "2015-01-06 AAPL 65797116\n", + "2015-01-07 AAPL 40105934\n", + "2015-01-08 AAPL 59364547\n", + "... ...\n", + "2020-08-24 MSFT 25460147\n", + "2020-08-25 MSFT 23043696\n", + "2020-08-26 MSFT 39600828\n", + "2020-08-27 MSFT 57602195\n", + "2020-08-28 MSFT 26292896\n", + "\n", + "[5700 rows x 1 columns]" ] }, - "execution_count": 132, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "vol['week'] = vol.index.week\n", - "vol['year'] = vol.index.year\n", - "\n", - "week = vol.groupby(['week','year']).sum()\n", - "week.head()" + "vol = df['volume']\n", + "vol = pd.DataFrame(vol)\n", + "vol" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 9. Find all the volume traded in the year of 2015" + "### Step 8. Aggregate the data of volume to weekly.\n", + "Hint: Be careful to not sum data from the same week of 2015 and other years." ] }, { "cell_type": "code", - "execution_count": 131, - "metadata": { - "collapsed": false - }, + "execution_count": 9, + "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "\n", " \n", " \n", " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", + " \n", " \n", " \n", " \n", @@ -407,79 +998,224 @@ " \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", "
stockAAPLIBMLNKDMSFTTSLA
yearweek
20151.301994e+101.100959e+09440376163.01.085839e+0920151532046265525341279138524764443
22828681872444036015859662422622034
33042266472327205615708813630799137
41987370413123079713735263216215501
54658426843292730743778677815720217
20166.081474e+096.585250e+08453233878.07.540962e+08..................
2020312118986092001057814937242261152261
322508525551770169721759895037091084
332354744731863465914175209171049854
342084647581590897813225802190804281
352659095311695979417199976288736115
\n", + "

296 rows × 4 columns

\n", "
" ], "text/plain": [ - " AAPL IBM LNKD TSLA\n", - "year \n", - "2015 1.301994e+10 1.100959e+09 440376163.0 1.085839e+09\n", - "2016 6.081474e+09 6.585250e+08 453233878.0 7.540962e+08" + "stock AAPL IBM MSFT TSLA\n", + "year week \n", + "2015 1 53204626 5525341 27913852 4764443\n", + " 2 282868187 24440360 158596624 22622034\n", + " 3 304226647 23272056 157088136 30799137\n", + " 4 198737041 31230797 137352632 16215501\n", + " 5 465842684 32927307 437786778 15720217\n", + "... ... ... ... ...\n", + "2020 31 211898609 20010578 149372422 61152261\n", + " 32 250852555 17701697 217598950 37091084\n", + " 33 235474473 18634659 141752091 71049854\n", + " 34 208464758 15908978 132258021 90804281\n", + " 35 265909531 16959794 171999762 88736115\n", + "\n", + "[296 rows x 4 columns]" ] }, - "execution_count": 131, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "del vol['week']\n", - "vol['year'] = vol.index.year\n", + "date = vol.index.get_level_values(0)\n", + "date = pd.DatetimeIndex(date) # ensure that it's a datetimeindex, instead of a regular index\n", + "\n", + "vol['week'] = date.isocalendar().week.values\n", + "# .values is necessary to obtain only the week *values*\n", + "# otherwise pandas interprets it as a part of an index; this would be a problem as the same week appears multiple times\n", + "# (same week number in different years, same week for different stocks)\n", + "\n", + "vol['year'] = date.year\n", "\n", - "year = vol.groupby(['year']).sum()\n", - "year" + "pd.pivot_table(vol, values='volume', index=['year', 'week'],\n", + " columns=['stock'], aggfunc=np.sum)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### BONUS: Create your own question and answer it." + "### Step 9. Find all the volume traded in the year of 2015" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] + "execution_count": 10, + "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", + "
stockAAPLIBMMSFTTSLA
year
201513064316775110554552190575823111086708380
\n", + "
" + ], + "text/plain": [ + "stock AAPL IBM MSFT TSLA\n", + "year \n", + "2015 13064316775 1105545521 9057582311 1086708380" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vol_2015 = vol[vol['year'] == 2015]\n", + "\n", + "pd.pivot_table(vol_2015, values='volume', index=['year'],\n", + " columns=['stock'], aggfunc=np.sum)" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" + "pygments_lexer": "ipython3", + "version": "3.6.8" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/09_Time_Series/Getting_Financial_Data/Solutions.ipynb b/09_Time_Series/Getting_Financial_Data/Solutions.ipynb index cad558f8d..9f1693e12 100644 --- a/09_Time_Series/Getting_Financial_Data/Solutions.ipynb +++ b/09_Time_Series/Getting_Financial_Data/Solutions.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Getting Financial Data - Google Finance" + "# Getting Financial Data - Pandas Datareader" ] }, { @@ -21,17 +21,16 @@ }, { "cell_type": "code", - "execution_count": 30, - "metadata": { - "collapsed": false - }, + "execution_count": 1, + "metadata": {}, "outputs": [], "source": [ + "import numpy as np\n", "import pandas as pd\n", "\n", "# package to extract data from various Internet sources into a DataFrame\n", "# make sure you have it installed\n", - "from pandas_datareader import data, wb\n", + "import pandas_datareader.data as web\n", "\n", "# package for dates\n", "import datetime as dt" @@ -41,15 +40,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 2. Create your time range (start and end variables). The start date should be 01/01/2015 and the end should today (whatever your today is)" + "### Step 2. Create your time range (start and end variables). The start date should be 01/01/2015 and the end should today (whatever your today is)." ] }, { "cell_type": "code", - "execution_count": 75, - "metadata": { - "collapsed": false - }, + "execution_count": 2, + "metadata": {}, "outputs": [ { "data": { @@ -57,7 +54,7 @@ "datetime.datetime(2015, 1, 1, 0, 0)" ] }, - "execution_count": 75, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -68,23 +65,165 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 3. Select the Apple, Tesla, Twitter, IBM, LinkedIn stocks symbols and assign them to a variable called stocks" + "### Step 3. Get an API key for one of the APIs that are supported by Pandas Datareader, preferably for AlphaVantage.\n", + "\n", + "If you do not have an API key for any of the supported APIs, it is easiest to get one for [AlphaVantage](https://www.alphavantage.co/support/#api-key). (Note that the API key is shown directly after the signup. You do *not* receive it via e-mail.)\n", + "\n", + "(For a full list of the APIs that are supported by Pandas Datareader, [see here](https://pydata.github.io/pandas-datareader/readers/index.html). As the APIs are provided by third parties, this list may change.)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Step 4. Use Pandas Datarader to read the daily time series for the Apple stock (ticker symbol AAPL) between 01/01/2015 and today, assign it to df_apple and print it." ] }, { "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, + "execution_count": 3, + "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", + "
openhighlowclosevolume
2015-01-02111.3900111.4400107.350109.3353204626
2015-01-05108.2900108.6500105.410106.2564285491
2015-01-06106.5400107.4300104.630106.2665797116
2015-01-07107.2000108.2000106.695107.7540105934
2015-01-08109.2300112.1500108.700111.8959364547
..................
2020-08-24514.7900515.1400495.745503.4386484442
2020-08-25498.7900500.7172492.210499.3052873947
2020-08-26504.7165507.9700500.330506.0940755567
2020-08-27508.5700509.9400495.330500.0438888096
2020-08-28504.0500505.7700498.310499.2346907479
\n", + "

1425 rows × 5 columns

\n", + "
" + ], "text/plain": [ - "['AAPL', 'TSLA', 'IBM', 'LNKD']" + " open high low close volume\n", + "2015-01-02 111.3900 111.4400 107.350 109.33 53204626\n", + "2015-01-05 108.2900 108.6500 105.410 106.25 64285491\n", + "2015-01-06 106.5400 107.4300 104.630 106.26 65797116\n", + "2015-01-07 107.2000 108.2000 106.695 107.75 40105934\n", + "2015-01-08 109.2300 112.1500 108.700 111.89 59364547\n", + "... ... ... ... ... ...\n", + "2020-08-24 514.7900 515.1400 495.745 503.43 86484442\n", + "2020-08-25 498.7900 500.7172 492.210 499.30 52873947\n", + "2020-08-26 504.7165 507.9700 500.330 506.09 40755567\n", + "2020-08-27 508.5700 509.9400 495.330 500.04 38888096\n", + "2020-08-28 504.0500 505.7700 498.310 499.23 46907479\n", + "\n", + "[1425 rows x 5 columns]" ] }, - "execution_count": 1, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -95,27 +234,166 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 4. Read the data from google, assign to df and print it" + "### Step 5. Add a new column \"stock\" to the dataframe and add the ticker symbol" ] }, { "cell_type": "code", - "execution_count": 77, - "metadata": { - "collapsed": false - }, + "execution_count": 4, + "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", + "
openhighlowclosevolumestock
2015-01-02111.3900111.4400107.350109.3353204626AAPL
2015-01-05108.2900108.6500105.410106.2564285491AAPL
2015-01-06106.5400107.4300104.630106.2665797116AAPL
2015-01-07107.2000108.2000106.695107.7540105934AAPL
2015-01-08109.2300112.1500108.700111.8959364547AAPL
.....................
2020-08-24514.7900515.1400495.745503.4386484442AAPL
2020-08-25498.7900500.7172492.210499.3052873947AAPL
2020-08-26504.7165507.9700500.330506.0940755567AAPL
2020-08-27508.5700509.9400495.330500.0438888096AAPL
2020-08-28504.0500505.7700498.310499.2346907479AAPL
\n", + "

1425 rows × 6 columns

\n", + "
" + ], "text/plain": [ - "\n", - "Dimensions: 5 (items) x 399 (major_axis) x 4 (minor_axis)\n", - "Items axis: Open to Volume\n", - "Major_axis axis: 2015-01-02 00:00:00 to 2016-08-02 00:00:00\n", - "Minor_axis axis: AAPL to TSLA" + " open high low close volume stock\n", + "2015-01-02 111.3900 111.4400 107.350 109.33 53204626 AAPL\n", + "2015-01-05 108.2900 108.6500 105.410 106.25 64285491 AAPL\n", + "2015-01-06 106.5400 107.4300 104.630 106.26 65797116 AAPL\n", + "2015-01-07 107.2000 108.2000 106.695 107.75 40105934 AAPL\n", + "2015-01-08 109.2300 112.1500 108.700 111.89 59364547 AAPL\n", + "... ... ... ... ... ... ...\n", + "2020-08-24 514.7900 515.1400 495.745 503.43 86484442 AAPL\n", + "2020-08-25 498.7900 500.7172 492.210 499.30 52873947 AAPL\n", + "2020-08-26 504.7165 507.9700 500.330 506.09 40755567 AAPL\n", + "2020-08-27 508.5700 509.9400 495.330 500.04 38888096 AAPL\n", + "2020-08-28 504.0500 505.7700 498.310 499.23 46907479 AAPL\n", + "\n", + "[1425 rows x 6 columns]" ] }, - "execution_count": 77, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -126,42 +404,180 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 5. What is the type of structure of df ?" + "### Step 6. Repeat the two previous steps for a few other stocks, always creating a new dataframe: Tesla, IBM and Microsoft. (Ticker symbols TSLA, IBM and MSFT.)" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, + "execution_count": 5, + "metadata": {}, "outputs": [], - "source": [ - "# 'pandas.core.panel.Panel'" - ] + "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 6. Print all the Items axis values\n", - "#### To learn more about the Panel structure go to [documentation](http://pandas.pydata.org/pandas-docs/stable/dsintro.html#panel) " + "### Step 7. Combine the four separate dataFrames into one combined dataFrame df that holds the information for all four stocks" ] }, { "cell_type": "code", - "execution_count": 120, - "metadata": { - "collapsed": false - }, + "execution_count": 6, + "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", + "
openhighlowclosevolumestock
2015-01-02111.39111.440107.350109.3353204626AAPL
2015-01-05108.29108.650105.410106.2564285491AAPL
2015-01-06106.54107.430104.630106.2665797116AAPL
2015-01-07107.20108.200106.695107.7540105934AAPL
2015-01-08109.23112.150108.700111.8959364547AAPL
.....................
2020-08-24214.79215.520212.430213.6925460147MSFT
2020-08-25213.10216.610213.100216.4723043696MSFT
2020-08-26217.88222.090217.360221.1539600828MSFT
2020-08-27222.89231.150219.400226.5857602195MSFT
2020-08-28228.18230.644226.580228.9126292896MSFT
\n", + "

5700 rows × 6 columns

\n", + "
" + ], "text/plain": [ - "Index([u'Open', u'High', u'Low', u'Close', u'Volume'], dtype='object')" + " open high low close volume stock\n", + "2015-01-02 111.39 111.440 107.350 109.33 53204626 AAPL\n", + "2015-01-05 108.29 108.650 105.410 106.25 64285491 AAPL\n", + "2015-01-06 106.54 107.430 104.630 106.26 65797116 AAPL\n", + "2015-01-07 107.20 108.200 106.695 107.75 40105934 AAPL\n", + "2015-01-08 109.23 112.150 108.700 111.89 59364547 AAPL\n", + "... ... ... ... ... ... ...\n", + "2020-08-24 214.79 215.520 212.430 213.69 25460147 MSFT\n", + "2020-08-25 213.10 216.610 213.100 216.47 23043696 MSFT\n", + "2020-08-26 217.88 222.090 217.360 221.15 39600828 MSFT\n", + "2020-08-27 222.89 231.150 219.400 226.58 57602195 MSFT\n", + "2020-08-28 228.18 230.644 226.580 228.91 26292896 MSFT\n", + "\n", + "[5700 rows x 6 columns]" ] }, - "execution_count": 120, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -172,31 +588,46 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 7. Good, now we know the data avaiable. Create a dataFrame called vol, with the Volume values." + "### Step 8. Shift the stock column into the index (making it a multi-level index consisting of the ticker symbol and the date)." ] }, { "cell_type": "code", - "execution_count": 122, - "metadata": { - "collapsed": false - }, + "execution_count": 7, + "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", @@ -206,54 +637,127 @@ " \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", "
AAPLIBMLNKDTSLAopenhighlowclosevolume
Datestock
2015-01-0253204626.05525466.01203743.04764443.0AAPL111.39111.440107.350109.3353204626
2015-01-0564285491.04880389.01400562.05368477.0AAPL108.29108.650105.410106.2564285491
2015-01-0665797116.06146712.02006546.06261936.0AAPL106.54107.430104.630106.2665797116
2015-01-0740105934.04701839.0985016.02968390.0AAPL107.20108.200106.695107.7540105934
2015-01-0859364547.04241113.01293955.03442509.0AAPL109.23112.150108.700111.8959364547
.....................
2020-08-24MSFT214.79215.520212.430213.6925460147
2020-08-25MSFT213.10216.610213.100216.4723043696
2020-08-26MSFT217.88222.090217.360221.1539600828
2020-08-27MSFT222.89231.150219.400226.5857602195
2020-08-28MSFT228.18230.644226.580228.9126292896
\n", + "

5700 rows × 5 columns

\n", "
" ], "text/plain": [ - " AAPL IBM LNKD TSLA\n", - "Date \n", - "2015-01-02 53204626.0 5525466.0 1203743.0 4764443.0\n", - "2015-01-05 64285491.0 4880389.0 1400562.0 5368477.0\n", - "2015-01-06 65797116.0 6146712.0 2006546.0 6261936.0\n", - "2015-01-07 40105934.0 4701839.0 985016.0 2968390.0\n", - "2015-01-08 59364547.0 4241113.0 1293955.0 3442509.0" + " open high low close volume\n", + " stock \n", + "2015-01-02 AAPL 111.39 111.440 107.350 109.33 53204626\n", + "2015-01-05 AAPL 108.29 108.650 105.410 106.25 64285491\n", + "2015-01-06 AAPL 106.54 107.430 104.630 106.26 65797116\n", + "2015-01-07 AAPL 107.20 108.200 106.695 107.75 40105934\n", + "2015-01-08 AAPL 109.23 112.150 108.700 111.89 59364547\n", + "... ... ... ... ... ...\n", + "2020-08-24 MSFT 214.79 215.520 212.430 213.69 25460147\n", + "2020-08-25 MSFT 213.10 216.610 213.100 216.47 23043696\n", + "2020-08-26 MSFT 217.88 222.090 217.360 221.15 39600828\n", + "2020-08-27 MSFT 222.89 231.150 219.400 226.58 57602195\n", + "2020-08-28 MSFT 228.18 230.644 226.580 228.91 26292896\n", + "\n", + "[5700 rows x 5 columns]" ] }, - "execution_count": 122, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -264,95 +768,124 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 8. Aggregate the data of Volume to weekly\n", - "#### Hint: Be careful to not sum data from the same week of 2015 and other years." + "### Step 7. Create a dataFrame called vol, with the volume values." ] }, { "cell_type": "code", - "execution_count": 132, - "metadata": { - "collapsed": false, - "scrolled": true - }, + "execution_count": 8, + "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", "
AAPLIBMLNKDTSLAvolume
weekyearstock
1201553204626.05525466.01203743.04764443.02015-01-02AAPL53204626
2016343422014.025233098.06630485.020967926.02015-01-05AAPL64285491
22015283252615.024458400.07203125.022709607.02015-01-06AAPL65797116
2016302072797.029379214.09160521.022997290.02015-01-07AAPL40105934
32015304226647.023263206.07084168.030799137.02015-01-08AAPL59364547
.........
2020-08-24MSFT25460147
2020-08-25MSFT23043696
2020-08-26MSFT39600828
2020-08-27MSFT57602195
2020-08-28MSFT26292896
\n", + "

5700 rows × 1 columns

\n", "
" ], "text/plain": [ - " AAPL IBM LNKD TSLA\n", - "week year \n", - "1 2015 53204626.0 5525466.0 1203743.0 4764443.0\n", - " 2016 343422014.0 25233098.0 6630485.0 20967926.0\n", - "2 2015 283252615.0 24458400.0 7203125.0 22709607.0\n", - " 2016 302072797.0 29379214.0 9160521.0 22997290.0\n", - "3 2015 304226647.0 23263206.0 7084168.0 30799137.0" + " volume\n", + " stock \n", + "2015-01-02 AAPL 53204626\n", + "2015-01-05 AAPL 64285491\n", + "2015-01-06 AAPL 65797116\n", + "2015-01-07 AAPL 40105934\n", + "2015-01-08 AAPL 59364547\n", + "... ...\n", + "2020-08-24 MSFT 25460147\n", + "2020-08-25 MSFT 23043696\n", + "2020-08-26 MSFT 39600828\n", + "2020-08-27 MSFT 57602195\n", + "2020-08-28 MSFT 26292896\n", + "\n", + "[5700 rows x 1 columns]" ] }, - "execution_count": 132, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -363,31 +896,45 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Step 9. Find all the volume traded in the year of 2015" + "### Step 8. Aggregate the data of volume to weekly.\n", + "Hint: Be careful to not sum data from the same week of 2015 and other years." ] }, { "cell_type": "code", - "execution_count": 131, - "metadata": { - "collapsed": false - }, + "execution_count": 9, + "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "\n", " \n", " \n", " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", + " \n", " \n", " \n", " \n", @@ -396,31 +943,109 @@ " \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", "
stockAAPLIBMLNKDMSFTTSLA
yearweek
20151.301994e+101.100959e+09440376163.01.085839e+0920151532046265525341279138524764443
22828681872444036015859662422622034
33042266472327205615708813630799137
41987370413123079713735263216215501
54658426843292730743778677815720217
..................
2020312118986092001057814937242261152261
322508525551770169721759895037091084
332354744731863465914175209171049854
20166.081474e+096.585250e+08453233878.07.540962e+08342084647581590897813225802190804281
352659095311695979417199976288736115
\n", + "

296 rows × 4 columns

\n", "
" ], "text/plain": [ - " AAPL IBM LNKD TSLA\n", - "year \n", - "2015 1.301994e+10 1.100959e+09 440376163.0 1.085839e+09\n", - "2016 6.081474e+09 6.585250e+08 453233878.0 7.540962e+08" + "stock AAPL IBM MSFT TSLA\n", + "year week \n", + "2015 1 53204626 5525341 27913852 4764443\n", + " 2 282868187 24440360 158596624 22622034\n", + " 3 304226647 23272056 157088136 30799137\n", + " 4 198737041 31230797 137352632 16215501\n", + " 5 465842684 32927307 437786778 15720217\n", + "... ... ... ... ...\n", + "2020 31 211898609 20010578 149372422 61152261\n", + " 32 250852555 17701697 217598950 37091084\n", + " 33 235474473 18634659 141752091 71049854\n", + " 34 208464758 15908978 132258021 90804281\n", + " 35 265909531 16959794 171999762 88736115\n", + "\n", + "[296 rows x 4 columns]" ] }, - "execution_count": 131, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -431,38 +1056,93 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### BONUS: Create your own question and answer it." + "### Step 9. Find all the volume traded in the year of 2015" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], + "execution_count": 10, + "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", + "
stockAAPLIBMMSFTTSLA
year
201513064316775110554552190575823111086708380
\n", + "
" + ], + "text/plain": [ + "stock AAPL IBM MSFT TSLA\n", + "year \n", + "2015 13064316775 1105545521 9057582311 1086708380" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" + "pygments_lexer": "ipython3", + "version": "3.7.4" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/09_Time_Series/Investor_Flow_of_Funds_US/Exercises_with_code_and_solutions.ipynb b/09_Time_Series/Investor_Flow_of_Funds_US/Exercises_with_code_and_solutions.ipynb index a60c955f6..85b201bdb 100644 --- a/09_Time_Series/Investor_Flow_of_Funds_US/Exercises_with_code_and_solutions.ipynb +++ b/09_Time_Series/Investor_Flow_of_Funds_US/Exercises_with_code_and_solutions.ipynb @@ -4,7 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Investor - Flow of Funds - US" + "# Investor - Flow of Funds - US\n", + "\n", + "Check out [Investor Flow of Funds Exercises Video Tutorial](https://youtu.be/QG6WbOgC9QE) to watch a data scientist go through the exercises" ] }, { @@ -21,9 +23,7 @@ { "cell_type": "code", "execution_count": 30, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "import pandas as pd" @@ -46,9 +46,7 @@ { "cell_type": "code", "execution_count": 31, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -171,9 +169,7 @@ { "cell_type": "code", "execution_count": 32, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# weekly data" @@ -189,9 +185,7 @@ { "cell_type": "code", "execution_count": 33, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -320,9 +314,7 @@ { "cell_type": "code", "execution_count": 34, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -361,9 +353,7 @@ { "cell_type": "code", "execution_count": 35, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -391,9 +381,7 @@ { "cell_type": "code", "execution_count": 36, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -834,9 +822,7 @@ { "cell_type": "code", "execution_count": 37, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -1069,9 +1055,7 @@ { "cell_type": "code", "execution_count": 38, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -1196,23 +1180,36 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" + "pygments_lexer": "ipython3", + "version": "3.7.3" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/10_Deleting/.DS_Store b/10_Deleting/.DS_Store index f37223950..b017d6d5a 100644 Binary files a/10_Deleting/.DS_Store and b/10_Deleting/.DS_Store differ diff --git a/10_Deleting/Iris/Exercises_with_solutions_and_code.ipynb b/10_Deleting/Iris/Exercises_with_solutions_and_code.ipynb index b6a1dca98..0414f7fd6 100644 --- a/10_Deleting/Iris/Exercises_with_solutions_and_code.ipynb +++ b/10_Deleting/Iris/Exercises_with_solutions_and_code.ipynb @@ -4,7 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Iris" + "# Iris\n", + "\n", + "Check out [Iris Exercises Video Tutorial](https://youtu.be/yAtzFLCWSZo) to watch a data scientist go through the exercises" ] }, { @@ -21,9 +23,7 @@ { "cell_type": "code", "execution_count": 13, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", @@ -47,9 +47,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -142,9 +140,7 @@ { "cell_type": "code", "execution_count": 5, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -241,9 +237,7 @@ { "cell_type": "code", "execution_count": 11, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -276,9 +270,7 @@ { "cell_type": "code", "execution_count": 36, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -504,9 +496,7 @@ { "cell_type": "code", "execution_count": 39, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -1104,9 +1094,7 @@ { "cell_type": "code", "execution_count": 40, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -1191,9 +1179,7 @@ { "cell_type": "code", "execution_count": 52, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -1278,9 +1264,7 @@ { "cell_type": "code", "execution_count": 53, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -1365,9 +1349,7 @@ { "cell_type": "code", "execution_count": 56, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -1461,23 +1443,36 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" + "pygments_lexer": "ipython3", + "version": "3.7.3" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/README.md b/README.md index a1cb6b3a8..8abf9b34d 100644 --- a/README.md +++ b/README.md @@ -23,51 +23,52 @@ Suggestions and collaborations are more than welcome.🙂 Please open an issue o |[Apply](#apply) | [Creating Series and DataFrames](#creating-series-and-dataframes) |Exporting| ### [Getting and knowing](https://github.com/guipsamora/pandas_exercises/tree/master/01_Getting_%26_Knowing_Your_Data) -[Chipotle](https://github.com/guipsamora/pandas_exercises/tree/master/01_Getting_%26_Knowing_Your_Data/Chipotle) -[Occupation](https://github.com/guipsamora/pandas_exercises/tree/master/01_Getting_%26_Knowing_Your_Data/Occupation) -[World Food Facts](https://github.com/guipsamora/pandas_exercises/tree/master/01_Getting_%26_Knowing_Your_Data/World%20Food%20Facts) +- [ ] [Chipotle](https://github.com/guipsamora/pandas_exercises/tree/master/01_Getting_%26_Knowing_Your_Data/Chipotle) +- [ ] [Occupation](https://github.com/guipsamora/pandas_exercises/tree/master/01_Getting_%26_Knowing_Your_Data/Occupation) +- [ ] [World Food Facts](https://github.com/guipsamora/pandas_exercises/tree/master/01_Getting_%26_Knowing_Your_Data/World%20Food%20Facts) + ### [Filtering and Sorting](https://github.com/guipsamora/pandas_exercises/tree/master/02_Filtering_%26_Sorting) -[Chipotle](https://github.com/guipsamora/pandas_exercises/tree/master/02_Filtering_%26_Sorting/Chipotle) -[Euro12](https://github.com/guipsamora/pandas_exercises/tree/master/02_Filtering_%26_Sorting/Euro12) -[Fictional Army](https://github.com/guipsamora/pandas_exercises/tree/master/02_Filtering_%26_Sorting/Fictional%20Army) +- [ ] [Chipotle](https://github.com/guipsamora/pandas_exercises/tree/master/02_Filtering_%26_Sorting/Chipotle) +- [ ] [Euro12](https://github.com/guipsamora/pandas_exercises/tree/master/02_Filtering_%26_Sorting/Euro12) +- [ ] [Fictional Army](https://github.com/guipsamora/pandas_exercises/tree/master/02_Filtering_%26_Sorting/Fictional%20Army) ### [Grouping](https://github.com/guipsamora/pandas_exercises/tree/master/03_Grouping) -[Alcohol Consumption](https://github.com/guipsamora/pandas_exercises/tree/master/03_Grouping/Alcohol_Consumption) -[Occupation](https://github.com/guipsamora/pandas_exercises/tree/master/03_Grouping/Occupation) -[Regiment](https://github.com/guipsamora/pandas_exercises/tree/master/03_Grouping/Regiment) +- [ ] [Alcohol Consumption](https://github.com/guipsamora/pandas_exercises/tree/master/03_Grouping/Alcohol_Consumption) +- [ ] [Occupation](https://github.com/guipsamora/pandas_exercises/tree/master/03_Grouping/Occupation) +- [ ] [Regiment](https://github.com/guipsamora/pandas_exercises/tree/master/03_Grouping/Regiment) ### [Apply](https://github.com/guipsamora/pandas_exercises/tree/master/04_Apply) -[Students Alcohol Consumption](https://github.com/guipsamora/pandas_exercises/tree/master/04_Apply/Students_Alcohol_Consumption) -[US_Crime_Rates](https://github.com/guipsamora/pandas_exercises/tree/master/04_Apply/US_Crime_Rates) +- [ ] [Students Alcohol Consumption](https://github.com/guipsamora/pandas_exercises/tree/master/04_Apply/Students_Alcohol_Consumption) +- [ ] [US_Crime_Rates](https://github.com/guipsamora/pandas_exercises/tree/master/04_Apply/US_Crime_Rates) ### [Merge](https://github.com/guipsamora/pandas_exercises/tree/master/05_Merge) -[Auto_MPG](https://github.com/guipsamora/pandas_exercises/tree/master/05_Merge/Auto_MPG) -[Fictitious Names](https://github.com/guipsamora/pandas_exercises/tree/master/05_Merge/Fictitous%20Names) -[House Market](https://github.com/guipsamora/pandas_exercises/tree/master/05_Merge/Housing%20Market) +- [ ] [Auto_MPG](https://github.com/guipsamora/pandas_exercises/tree/master/05_Merge/Auto_MPG) +- [ ] [Fictitious Names](https://github.com/guipsamora/pandas_exercises/tree/master/05_Merge/Fictitous%20Names) +- [ ] [House Market](https://github.com/guipsamora/pandas_exercises/tree/master/05_Merge/Housing%20Market) ### [Stats](https://github.com/guipsamora/pandas_exercises/tree/master/06_Stats) -[US_Baby_Names](https://github.com/guipsamora/pandas_exercises/tree/master/06_Stats/US_Baby_Names) -[Wind_Stats](https://github.com/guipsamora/pandas_exercises/tree/master/06_Stats/Wind_Stats) +- [ ] [US_Baby_Names](https://github.com/guipsamora/pandas_exercises/tree/master/06_Stats/US_Baby_Names) +- [ ] [Wind_Stats](https://github.com/guipsamora/pandas_exercises/tree/master/06_Stats/Wind_Stats) ### [Visualization](https://github.com/guipsamora/pandas_exercises/tree/master/07_Visualization) -[Chipotle](https://github.com/guipsamora/pandas_exercises/tree/master/07_Visualization/Chipotle) -[Titanic Disaster](https://github.com/guipsamora/pandas_exercises/tree/master/07_Visualization/Titanic_Desaster) -[Scores](https://github.com/guipsamora/pandas_exercises/tree/master/07_Visualization/Scores) -[Online Retail](https://github.com/guipsamora/pandas_exercises/tree/master/07_Visualization/Online_Retail) -[Tips](https://github.com/guipsamora/pandas_exercises/tree/master/07_Visualization/Tips) +- [ ] [Chipotle](https://github.com/guipsamora/pandas_exercises/tree/master/07_Visualization/Chipotle) +- [ ] [Titanic Disaster](https://github.com/guipsamora/pandas_exercises/tree/master/07_Visualization/Titanic_Desaster) +- [ ] [Scores](https://github.com/guipsamora/pandas_exercises/tree/master/07_Visualization/Scores) +- [ ] [Online Retail](https://github.com/guipsamora/pandas_exercises/tree/master/07_Visualization/Online_Retail) +- [ ] [Tips](https://github.com/guipsamora/pandas_exercises/tree/master/07_Visualization/Tips) ### [Creating Series and DataFrames](https://github.com/guipsamora/pandas_exercises/tree/master/08_Creating_Series_and_DataFrames) -[Pokemon](https://github.com/guipsamora/pandas_exercises/tree/master/08_Creating_Series_and_DataFrames/Pokemon) +- [ ] [Pokemon](https://github.com/guipsamora/pandas_exercises/tree/master/08_Creating_Series_and_DataFrames/Pokemon) ### [Time Series](https://github.com/guipsamora/pandas_exercises/tree/master/09_Time_Series) -[Apple_Stock](https://github.com/guipsamora/pandas_exercises/tree/master/09_Time_Series/Apple_Stock) -[Getting_Financial_Data](https://github.com/guipsamora/pandas_exercises/tree/master/09_Time_Series/Getting_Financial_Data) -[Investor_Flow_of_Funds_US](https://github.com/guipsamora/pandas_exercises/tree/master/09_Time_Series/Getting_Financial_Data) +- [ ] [Apple_Stock](https://github.com/guipsamora/pandas_exercises/tree/master/09_Time_Series/Apple_Stock) +- [ ] [Getting_Financial_Data](https://github.com/guipsamora/pandas_exercises/tree/master/09_Time_Series/Getting_Financial_Data) +- [ ] [Investor_Flow_of_Funds_US](https://github.com/guipsamora/pandas_exercises/tree/master/09_Time_Series/Getting_Financial_Data) ### [Deleting](https://github.com/guipsamora/pandas_exercises/tree/master/10_Deleting) -[Iris](https://github.com/guipsamora/pandas_exercises/tree/master/10_Deleting/Iris) -[Wine](https://github.com/guipsamora/pandas_exercises/tree/master/10_Deleting/Wine) +- [ ] [Iris](https://github.com/guipsamora/pandas_exercises/tree/master/10_Deleting/Iris) +- [ ] [Wine](https://github.com/guipsamora/pandas_exercises/tree/master/10_Deleting/Wine) # Video Solutions diff --git a/requirements.txt b/requirements.txt index 45d521309..4a0ad3abb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -numpy==1.13.1 +numpy==1.22.0 matplotlib==2.0.2 seaborn==0.8.1 pandas==0.23.4 \ No newline at end of file