diff --git a/04_Apply/US_Crime_Rates/Exercises_with_solutions.ipynb b/04_Apply/US_Crime_Rates/Exercises_with_solutions.ipynb index 6687d0e8..ea83f035 100644 --- a/04_Apply/US_Crime_Rates/Exercises_with_solutions.ipynb +++ b/04_Apply/US_Crime_Rates/Exercises_with_solutions.ipynb @@ -24,7 +24,9 @@ }, { "cell_type": "code", - "execution_count": 95, + "execution_count": 1, + + "metadata": {}, "outputs": [], "source": [ @@ -48,13 +50,28 @@ }, { "cell_type": "code", - "execution_count": 265, + + "execution_count": 2, + "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "\n", " \n", " \n", @@ -169,7 +186,7 @@ "4 130390 203050 1213200 2514400 472800 " ] }, - "execution_count": 265, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -189,7 +206,10 @@ }, { "cell_type": "code", - "execution_count": 266, + + "execution_count": 3, + + "metadata": {}, "outputs": [ { @@ -199,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" ] } ], @@ -231,7 +253,9 @@ }, { "cell_type": "code", - "execution_count": 267, + + "execution_count": 4, + "metadata": {}, "outputs": [ { @@ -241,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" ] } ], @@ -273,13 +299,28 @@ }, { "cell_type": "code", - "execution_count": 268, + + "execution_count": 5, + "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -412,7 +453,7 @@ "1964-01-01 472800 " ] }, - "execution_count": 268, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -431,13 +472,28 @@ }, { "cell_type": "code", - "execution_count": 269, + + "execution_count": 6, + "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -555,7 +611,7 @@ "1964-01-01 203050 1213200 2514400 472800 " ] }, - "execution_count": 269, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -576,7 +632,7 @@ }, { "cell_type": "code", - "execution_count": 270, + "execution_count": 7, "metadata": { "scrolled": true }, @@ -585,6 +641,19 @@ "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -600,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", @@ -616,7 +698,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -629,7 +711,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -642,7 +724,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -655,7 +737,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -668,7 +750,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -685,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" } @@ -732,34 +816,43 @@ }, { "cell_type": "code", - "execution_count": 276, + + "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": { @@ -779,7 +872,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + + "version": "3.7.6" + }, "toc": { "base_numbering": 1, @@ -793,6 +888,7 @@ "toc_position": {}, "toc_section_display": true, "toc_window_display": false + } }, "nbformat": 4,
Larceny_TheftVehicle_Theft
Year
19601960-01-012013850004134930451609005292100
19701970-01-012200990009607930913838009739900
19801980-01-012482390001407432811704890011935411
19901990-01-012726908131752704811905349914624418
20002000-01-013070065501396805610094436911412834
20102010-01-01318857056607201744095950