├── Week3-1-4-Analyzing-v5-py.ipynb ├── test_notebook_final.ipynb └── running_sql_db.ipynb /Week3-1-4-Analyzing-v5-py.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Introduction\n", 8 | "\n", 9 | "This notebook shows how to store a dataset into a database using and analyze data using SQL and Python. In this lab you will:\n", 10 | "1. Understand a dataset of selected socioeconomic indicators in Chicago\n", 11 | "1. Learn how to store data in an Db2 database on IBM Cloud instance\n", 12 | "1. Solve example problems to practice your SQL skills " 13 | ] 14 | }, 15 | { 16 | "cell_type": "markdown", 17 | "metadata": {}, 18 | "source": [ 19 | "## Selected Socioeconomic Indicators in Chicago\n", 20 | "\n", 21 | "The city of Chicago released a dataset of socioeconomic data to the Chicago City Portal.\n", 22 | "This dataset contains a selection of six socioeconomic indicators of public health significance and a “hardship index,” for each Chicago community area, for the years 2008 – 2012.\n", 23 | "\n", 24 | "Scores on the hardship index can range from 1 to 100, with a higher index number representing a greater level of hardship.\n", 25 | "\n", 26 | "A detailed description of the dataset can be found on [the city of Chicago's website](\n", 27 | "https://data.cityofchicago.org/Health-Human-Services/Census-Data-Selected-socioeconomic-indicators-in-C/kn9c-c2s2), but to summarize, the dataset has the following variables:\n", 28 | "\n", 29 | "* **Community Area Number** (`ca`): Used to uniquely identify each row of the dataset\n", 30 | "\n", 31 | "* **Community Area Name** (`community_area_name`): The name of the region in the city of Chicago \n", 32 | "\n", 33 | "* **Percent of Housing Crowded** (`percent_of_housing_crowded`): Percent of occupied housing units with more than one person per room\n", 34 | "\n", 35 | "* **Percent Households Below Poverty** (`percent_households_below_poverty`): Percent of households living below the federal poverty line\n", 36 | "\n", 37 | "* **Percent Aged 16+ Unemployed** (`percent_aged_16_unemployed`): Percent of persons over the age of 16 years that are unemployed\n", 38 | "\n", 39 | "* **Percent Aged 25+ without High School Diploma** (`percent_aged_25_without_high_school_diploma`): Percent of persons over the age of 25 years without a high school education\n", 40 | "\n", 41 | "* **Percent Aged Under** 18 or Over 64:Percent of population under 18 or over 64 years of age (`percent_aged_under_18_or_over_64`): (ie. dependents)\n", 42 | "\n", 43 | "* **Per Capita Income** (`per_capita_income_`): Community Area per capita income is estimated as the sum of tract-level aggragate incomes divided by the total population\n", 44 | "\n", 45 | "* **Hardship Index** (`hardship_index`): Score that incorporates each of the six selected socioeconomic indicators\n", 46 | "\n", 47 | "In this Lab, we'll take a look at the variables in the socioeconomic indicators dataset and do some basic analysis with Python.\n" 48 | ] 49 | }, 50 | { 51 | "cell_type": "markdown", 52 | "metadata": {}, 53 | "source": [ 54 | "### Connect to the database\n", 55 | "Let us first load the SQL extension and establish a connection with the database" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": 4, 61 | "metadata": {}, 62 | "outputs": [], 63 | "source": [ 64 | "%load_ext sql" 65 | ] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "execution_count": 5, 70 | "metadata": {}, 71 | "outputs": [ 72 | { 73 | "data": { 74 | "text/plain": [ 75 | "'Connected: tnx67692@BLUDB'" 76 | ] 77 | }, 78 | "execution_count": 5, 79 | "metadata": {}, 80 | "output_type": "execute_result" 81 | } 82 | ], 83 | "source": [ 84 | "# Remember the connection string is of the format:\n", 85 | "# %sql ibm_db_sa://my-username:my-password@my-hostname:my-port/my-db-name\n", 86 | "%sql ibm_db_sa://tnx67692:03p3756+ntd6sgr9@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB" 87 | ] 88 | }, 89 | { 90 | "cell_type": "markdown", 91 | "metadata": {}, 92 | "source": [ 93 | "### Store the dataset in a Table\n", 94 | "##### In many cases the dataset to be analyzed is available as a .CSV (comma separated values) file, perhaps on the internet. To analyze the data using SQL, it first needs to be stored in the database.\n", 95 | "\n", 96 | "##### We will first read the dataset source .CSV from the internet into pandas dataframe\n", 97 | "\n", 98 | "##### Then we need to create a table in our Db2 database to store the dataset. The PERSIST command in SQL \"magic\" simplifies the process of table creation and writing the data from a `pandas` dataframe into the table" 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": 6, 104 | "metadata": {}, 105 | "outputs": [ 106 | { 107 | "name": "stdout", 108 | "output_type": "stream", 109 | "text": [ 110 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 111 | "Done.\n", 112 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n" 113 | ] 114 | }, 115 | { 116 | "data": { 117 | "text/plain": [ 118 | "'Persisted chicago_socioeconomic_data'" 119 | ] 120 | }, 121 | "execution_count": 6, 122 | "metadata": {}, 123 | "output_type": "execute_result" 124 | } 125 | ], 126 | "source": [ 127 | "%sql drop table chicago_socioeconomic_data\n", 128 | "import pandas\n", 129 | "chicago_socioeconomic_data = pandas.read_csv('https://data.cityofchicago.org/resource/jcxq-k9xf.csv')\n", 130 | "%sql PERSIST chicago_socioeconomic_data" 131 | ] 132 | }, 133 | { 134 | "cell_type": "markdown", 135 | "metadata": {}, 136 | "source": [ 137 | "##### You can verify that the table creation was successful by making a basic query like:" 138 | ] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "execution_count": 7, 143 | "metadata": {}, 144 | "outputs": [ 145 | { 146 | "name": "stdout", 147 | "output_type": "stream", 148 | "text": [ 149 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 150 | "Done.\n" 151 | ] 152 | }, 153 | { 154 | "data": { 155 | "text/html": [ 156 | "\n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 161 | " \n", 162 | " \n", 163 | " \n", 164 | " \n", 165 | " \n", 166 | " \n", 167 | " \n", 168 | " \n", 169 | " \n", 170 | " \n", 171 | " \n", 172 | " \n", 173 | " \n", 174 | " \n", 175 | " \n", 176 | " \n", 177 | " \n", 178 | " \n", 179 | " \n", 180 | " \n", 181 | " \n", 182 | " \n", 183 | " \n", 184 | " \n", 185 | " \n", 186 | " \n", 187 | " \n", 188 | " \n", 189 | " \n", 190 | " \n", 191 | " \n", 192 | " \n", 193 | " \n", 194 | " \n", 195 | " \n", 196 | " \n", 197 | " \n", 198 | " \n", 199 | " \n", 200 | " \n", 201 | " \n", 202 | " \n", 203 | " \n", 204 | " \n", 205 | " \n", 206 | " \n", 207 | " \n", 208 | " \n", 209 | " \n", 210 | " \n", 211 | " \n", 212 | " \n", 213 | " \n", 214 | " \n", 215 | " \n", 216 | " \n", 217 | " \n", 218 | " \n", 219 | " \n", 220 | " \n", 221 | " \n", 222 | " \n", 223 | " \n", 224 | " \n", 225 | " \n", 226 | " \n", 227 | " \n", 228 | " \n", 229 | "
indexcacommunity_area_namepercent_of_housing_crowdedpercent_households_below_povertypercent_aged_16_unemployedpercent_aged_25_without_high_school_diplomapercent_aged_under_18_or_over_64per_capita_income_hardship_index
01.0Rogers Park7.723.68.718.227.52393939.0
12.0West Ridge7.817.28.820.838.52304046.0
23.0Uptown3.824.08.911.822.23578720.0
34.0Lincoln Square3.410.98.213.425.53752417.0
45.0North Center0.37.55.24.526.2571236.0
" 230 | ], 231 | "text/plain": [ 232 | "[(0, 1.0, 'Rogers Park', 7.7, 23.6, 8.7, 18.2, 27.5, 23939, 39.0),\n", 233 | " (1, 2.0, 'West Ridge', 7.8, 17.2, 8.8, 20.8, 38.5, 23040, 46.0),\n", 234 | " (2, 3.0, 'Uptown', 3.8, 24.0, 8.9, 11.8, 22.2, 35787, 20.0),\n", 235 | " (3, 4.0, 'Lincoln Square', 3.4, 10.9, 8.2, 13.4, 25.5, 37524, 17.0),\n", 236 | " (4, 5.0, 'North Center', 0.3, 7.5, 5.2, 4.5, 26.2, 57123, 6.0)]" 237 | ] 238 | }, 239 | "execution_count": 7, 240 | "metadata": {}, 241 | "output_type": "execute_result" 242 | } 243 | ], 244 | "source": [ 245 | "%sql SELECT * FROM chicago_socioeconomic_data limit 5;" 246 | ] 247 | }, 248 | { 249 | "cell_type": "markdown", 250 | "metadata": {}, 251 | "source": [ 252 | "## Problems\n", 253 | "\n", 254 | "### Problem 1\n", 255 | "\n", 256 | "##### How many rows are in the dataset?" 257 | ] 258 | }, 259 | { 260 | "cell_type": "code", 261 | "execution_count": 8, 262 | "metadata": {}, 263 | "outputs": [ 264 | { 265 | "data": { 266 | "text/plain": [ 267 | "(78, 9)" 268 | ] 269 | }, 270 | "execution_count": 8, 271 | "metadata": {}, 272 | "output_type": "execute_result" 273 | } 274 | ], 275 | "source": [ 276 | "chicago_socioeconomic_data.shape" 277 | ] 278 | }, 279 | { 280 | "cell_type": "markdown", 281 | "metadata": {}, 282 | "source": [ 283 | "### Problem 2\n", 284 | "\n", 285 | "##### How many community areas in Chicago have a hardship index greater than 50.0?" 286 | ] 287 | }, 288 | { 289 | "cell_type": "code", 290 | "execution_count": 9, 291 | "metadata": {}, 292 | "outputs": [ 293 | { 294 | "name": "stdout", 295 | "output_type": "stream", 296 | "text": [ 297 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 298 | "Done.\n" 299 | ] 300 | }, 301 | { 302 | "data": { 303 | "text/html": [ 304 | "\n", 305 | " \n", 306 | " \n", 307 | " \n", 308 | " \n", 309 | " \n", 310 | " \n", 311 | "
1
38
" 312 | ], 313 | "text/plain": [ 314 | "[(Decimal('38'),)]" 315 | ] 316 | }, 317 | "execution_count": 9, 318 | "metadata": {}, 319 | "output_type": "execute_result" 320 | } 321 | ], 322 | "source": [ 323 | "%sql select count(*) FROM chicago_socioeconomic_data where hardship_index > 50" 324 | ] 325 | }, 326 | { 327 | "cell_type": "markdown", 328 | "metadata": {}, 329 | "source": [ 330 | "### Problem 3\n", 331 | "\n", 332 | "##### What is the maximum value of hardship index in this dataset?" 333 | ] 334 | }, 335 | { 336 | "cell_type": "code", 337 | "execution_count": 10, 338 | "metadata": {}, 339 | "outputs": [ 340 | { 341 | "name": "stdout", 342 | "output_type": "stream", 343 | "text": [ 344 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 345 | "Done.\n" 346 | ] 347 | }, 348 | { 349 | "data": { 350 | "text/html": [ 351 | "\n", 352 | " \n", 353 | " \n", 354 | " \n", 355 | " \n", 356 | " \n", 357 | " \n", 358 | "
1
98.0
" 359 | ], 360 | "text/plain": [ 361 | "[(98.0,)]" 362 | ] 363 | }, 364 | "execution_count": 10, 365 | "metadata": {}, 366 | "output_type": "execute_result" 367 | } 368 | ], 369 | "source": [ 370 | "%sql select max(hardship_index) from chicago_socioeconomic_data" 371 | ] 372 | }, 373 | { 374 | "cell_type": "markdown", 375 | "metadata": {}, 376 | "source": [ 377 | "### Problem 4\n", 378 | "\n", 379 | "##### Which community area which has the highest hardship index?\n" 380 | ] 381 | }, 382 | { 383 | "cell_type": "code", 384 | "execution_count": 11, 385 | "metadata": {}, 386 | "outputs": [ 387 | { 388 | "name": "stdout", 389 | "output_type": "stream", 390 | "text": [ 391 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 392 | "Done.\n" 393 | ] 394 | }, 395 | { 396 | "data": { 397 | "text/html": [ 398 | "\n", 399 | " \n", 400 | " \n", 401 | " \n", 402 | " \n", 403 | " \n", 404 | " \n", 405 | "
community_area_name
Riverdale
" 406 | ], 407 | "text/plain": [ 408 | "[('Riverdale',)]" 409 | ] 410 | }, 411 | "execution_count": 11, 412 | "metadata": {}, 413 | "output_type": "execute_result" 414 | } 415 | ], 416 | "source": [ 417 | "%sql select community_area_name from chicago_socioeconomic_data where hardship_index = (select max(hardship_index) from chicago_socioeconomic_data)" 418 | ] 419 | }, 420 | { 421 | "cell_type": "markdown", 422 | "metadata": {}, 423 | "source": [ 424 | "### Problem 5\n", 425 | "\n", 426 | "##### Which Chicago community areas have per-capita incomes greater than $60,000?" 427 | ] 428 | }, 429 | { 430 | "cell_type": "code", 431 | "execution_count": 12, 432 | "metadata": {}, 433 | "outputs": [ 434 | { 435 | "name": "stdout", 436 | "output_type": "stream", 437 | "text": [ 438 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 439 | "Done.\n" 440 | ] 441 | }, 442 | { 443 | "data": { 444 | "text/html": [ 445 | "\n", 446 | " \n", 447 | " \n", 448 | " \n", 449 | " \n", 450 | " \n", 451 | " \n", 452 | " \n", 453 | " \n", 454 | " \n", 455 | " \n", 456 | " \n", 457 | " \n", 458 | " \n", 459 | " \n", 460 | " \n", 461 | "
community_area_name
Lake View
Lincoln Park
Near North Side
Loop
" 462 | ], 463 | "text/plain": [ 464 | "[('Lake View',), ('Lincoln Park',), ('Near North Side',), ('Loop',)]" 465 | ] 466 | }, 467 | "execution_count": 12, 468 | "metadata": {}, 469 | "output_type": "execute_result" 470 | } 471 | ], 472 | "source": [ 473 | "%sql select community_area_name from chicago_socioeconomic_data where per_capita_income_ > 60000" 474 | ] 475 | }, 476 | { 477 | "cell_type": "markdown", 478 | "metadata": {}, 479 | "source": [ 480 | "### Problem 6\n", 481 | "\n", 482 | "##### Create a scatter plot using the variables `per_capita_income_` and `hardship_index`. Explain the correlation between the two variables." 483 | ] 484 | }, 485 | { 486 | "cell_type": "code", 487 | "execution_count": 13, 488 | "metadata": {}, 489 | "outputs": [ 490 | { 491 | "data": { 492 | "text/plain": [ 493 | "Text(0.5, 1, 'Hardship vs Income')" 494 | ] 495 | }, 496 | "execution_count": 13, 497 | "metadata": {}, 498 | "output_type": "execute_result" 499 | }, 500 | { 501 | "data": { 502 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAc0AAAGoCAYAAAAkfL70AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0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FWWOkMEnyc5LXM5LnqQptyp6bLLuk9yev/0XS0uT1xZLmJa8fVGpezdS+epKY5tSJ5waFs9TKsU5MXv+bpE+MF7OkV0v6paQ9Je2l0Mrv8ORntl3SKxX+g3tL8nMzhVk/Lk/28xlJ85PXeytMdL5n2b9zHjw68cGZJibTQ+7+s+T1SklvlXSYpOsszPH5Ce0888O3G+zvzZK+LD075dlIsv4jZnaHpP9RmC1idrL+mdQ+Vyr0BW7k3WZ2q0LP3ldIir1m+bTCZMlSSHaz6sR8lKTL3P0pd39SYRaPNyTbP+Duv3T3ZxSS6Rp3d4UkW9nnWySdlfwMb1DoXXpQZJwAMugtOwB0leoL6JslrXP314+z/VNZD2Bmb1SYveX17r7FzG5QSCIx8VTv6xBJ/yjpNe7+ezO7uM6+qo0myU2SxlT/31qt+RMrtqVeP5Nafia1T5P0Tne/OzI2AE3iTBOT6SAzqyTI9yqcCc6srDOzPjN7RYb9rZH0d8lne8xsukK58/dJwnyZpNeltp+iMNWSJL1P0k9r7HOzpGnJ6+kKiXskuSY5N0NsWWK+UdLJyTXePSX9pcJMGrGukXRGMsWUzOzwHOIEUANJE5NpvaTTzGytpBmSLlBIYp9Nyqm3K0wuHOtMSW8ys18qlEBfIelqSb3JMf5VITFXPCXpFWZ2i0KZ9FM19rlM0mozu97d71Aoy65TuJb4sxrbZ7VLzO5+q8J11Zsl3SRpubvflmGf/yqpT9JaM7szWQZQAG45waQws1kKc2YeVmIMT7r7XmUdH0D740wTAIBInGmi5ZnZOZLeVbX6u+7+6ZLiuUzSIVWr/8ndrykjnlrM7K2SPlu1+gF3/8sy4gE6BUkTAIBIlGcBAIhE0gQAIBJJEwCASCRNAAAi/X/HzjpbagWFiAAAAABJRU5ErkJggg==\n", 503 | "text/plain": [ 504 | "
" 505 | ] 506 | }, 507 | "metadata": { 508 | "needs_background": "light" 509 | }, 510 | "output_type": "display_data" 511 | } 512 | ], 513 | "source": [ 514 | "import matplotlib.pyplot as plt\n", 515 | "%matplotlib inline\n", 516 | "import seaborn as sns\n", 517 | "\n", 518 | "plot = sns.jointplot(x = 'per_capita_income_', y = 'hardship_index', data = chicago_socioeconomic_data, color='red', s=100)\n", 519 | "plt.title('Hardship vs Income')" 520 | ] 521 | }, 522 | { 523 | "cell_type": "markdown", 524 | "metadata": {}, 525 | "source": [ 526 | "### Conclusion\n", 527 | "\n", 528 | "##### Now that you know how to do basic exploratory data analysis using SQL and python visualization tools, you can further explore this dataset to see how the variable `per_capita_income_` is related to `percent_households_below_poverty` and `percent_aged_16_unemployed`. Try to create interesting visualizations!" 529 | ] 530 | } 531 | ], 532 | "metadata": { 533 | "kernelspec": { 534 | "display_name": "Python", 535 | "language": "python", 536 | "name": "conda-env-python-py" 537 | }, 538 | "language_info": { 539 | "codemirror_mode": { 540 | "name": "ipython", 541 | "version": 3 542 | }, 543 | "file_extension": ".py", 544 | "mimetype": "text/x-python", 545 | "name": "python", 546 | "nbconvert_exporter": "python", 547 | "pygments_lexer": "ipython3", 548 | "version": "3.6.7" 549 | }, 550 | "widgets": { 551 | "state": {}, 552 | "version": "1.1.2" 553 | } 554 | }, 555 | "nbformat": 4, 556 | "nbformat_minor": 4 557 | } 558 | -------------------------------------------------------------------------------- /test_notebook_final.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "

Analyzing US Economic Data and Building a Dashboard

\n", 15 | "

Description

\n" 16 | ] 17 | }, 18 | { 19 | "cell_type": "markdown", 20 | "metadata": {}, 21 | "source": [ 22 | "Extracting essential data from a dataset and displaying it is a necessary part of data science; therefore individuals can make correct decisions based on the data. In this assignment, you will extract some essential economic indicators from some data, you will then display these economic indicators in a Dashboard. You can then share the dashboard via an URL.\n", 23 | "

\n", 24 | " Gross domestic product (GDP) is a measure of the market value of all the final goods and services produced in a period. GDP is an indicator of how well the economy is doing. A drop in GDP indicates the economy is producing less; similarly an increase in GDP suggests the economy is performing better. In this lab, you will examine how changes in GDP impact the unemployment rate. You will take screen shots of every step, you will share the notebook and the URL pointing to the dashboard.

" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "

Table of Contents

\n", 32 | "
\n", 33 | " \n", 41 | "

\n", 42 | " Estimated Time Needed: 180 min

\n", 43 | "
\n", 44 | "\n", 45 | "
" 46 | ] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "metadata": {}, 51 | "source": [ 52 | "

Define Function that Makes a Dashboard

" 53 | ] 54 | }, 55 | { 56 | "cell_type": "markdown", 57 | "metadata": {}, 58 | "source": [ 59 | "We will import the libraries." 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": 2, 65 | "metadata": {}, 66 | "outputs": [ 67 | { 68 | "data": { 69 | "text/html": [ 70 | "\n", 71 | "
\n", 72 | " \n", 73 | " Loading BokehJS ...\n", 74 | "
" 75 | ] 76 | }, 77 | "metadata": {}, 78 | "output_type": "display_data" 79 | }, 80 | { 81 | "data": { 82 | "application/javascript": [ 83 | "\n", 84 | "(function(root) {\n", 85 | " function now() {\n", 86 | " return new Date();\n", 87 | " }\n", 88 | "\n", 89 | " var force = true;\n", 90 | "\n", 91 | " if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", 92 | " root._bokeh_onload_callbacks = [];\n", 93 | " root._bokeh_is_loading = undefined;\n", 94 | " }\n", 95 | "\n", 96 | " var JS_MIME_TYPE = 'application/javascript';\n", 97 | " var HTML_MIME_TYPE = 'text/html';\n", 98 | " var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n", 99 | " var CLASS_NAME = 'output_bokeh rendered_html';\n", 100 | "\n", 101 | " /**\n", 102 | " * Render data to the DOM node\n", 103 | " */\n", 104 | " function render(props, node) {\n", 105 | " var script = document.createElement(\"script\");\n", 106 | " node.appendChild(script);\n", 107 | " }\n", 108 | "\n", 109 | " /**\n", 110 | " * Handle when an output is cleared or removed\n", 111 | " */\n", 112 | " function handleClearOutput(event, handle) {\n", 113 | " var cell = handle.cell;\n", 114 | "\n", 115 | " var id = cell.output_area._bokeh_element_id;\n", 116 | " var server_id = cell.output_area._bokeh_server_id;\n", 117 | " // Clean up Bokeh references\n", 118 | " if (id != null && id in Bokeh.index) {\n", 119 | " Bokeh.index[id].model.document.clear();\n", 120 | " delete Bokeh.index[id];\n", 121 | " }\n", 122 | "\n", 123 | " if (server_id !== undefined) {\n", 124 | " // Clean up Bokeh references\n", 125 | " var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n", 126 | " cell.notebook.kernel.execute(cmd, {\n", 127 | " iopub: {\n", 128 | " output: function(msg) {\n", 129 | " var id = msg.content.text.trim();\n", 130 | " if (id in Bokeh.index) {\n", 131 | " Bokeh.index[id].model.document.clear();\n", 132 | " delete Bokeh.index[id];\n", 133 | " }\n", 134 | " }\n", 135 | " }\n", 136 | " });\n", 137 | " // Destroy server and session\n", 138 | " var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n", 139 | " cell.notebook.kernel.execute(cmd);\n", 140 | " }\n", 141 | " }\n", 142 | "\n", 143 | " /**\n", 144 | " * Handle when a new output is added\n", 145 | " */\n", 146 | " function handleAddOutput(event, handle) {\n", 147 | " var output_area = handle.output_area;\n", 148 | " var output = handle.output;\n", 149 | "\n", 150 | " // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n", 151 | " if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n", 152 | " return\n", 153 | " }\n", 154 | "\n", 155 | " var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n", 156 | "\n", 157 | " if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n", 158 | " toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n", 159 | " // store reference to embed id on output_area\n", 160 | " output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n", 161 | " }\n", 162 | " if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n", 163 | " var bk_div = document.createElement(\"div\");\n", 164 | " bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n", 165 | " var script_attrs = bk_div.children[0].attributes;\n", 166 | " for (var i = 0; i < script_attrs.length; i++) {\n", 167 | " toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n", 168 | " }\n", 169 | " // store reference to server id on output_area\n", 170 | " output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n", 171 | " }\n", 172 | " }\n", 173 | "\n", 174 | " function register_renderer(events, OutputArea) {\n", 175 | "\n", 176 | " function append_mime(data, metadata, element) {\n", 177 | " // create a DOM node to render to\n", 178 | " var toinsert = this.create_output_subarea(\n", 179 | " metadata,\n", 180 | " CLASS_NAME,\n", 181 | " EXEC_MIME_TYPE\n", 182 | " );\n", 183 | " this.keyboard_manager.register_events(toinsert);\n", 184 | " // Render to node\n", 185 | " var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n", 186 | " render(props, toinsert[toinsert.length - 1]);\n", 187 | " element.append(toinsert);\n", 188 | " return toinsert\n", 189 | " }\n", 190 | "\n", 191 | " /* Handle when an output is cleared or removed */\n", 192 | " events.on('clear_output.CodeCell', handleClearOutput);\n", 193 | " events.on('delete.Cell', handleClearOutput);\n", 194 | "\n", 195 | " /* Handle when a new output is added */\n", 196 | " events.on('output_added.OutputArea', handleAddOutput);\n", 197 | "\n", 198 | " /**\n", 199 | " * Register the mime type and append_mime function with output_area\n", 200 | " */\n", 201 | " OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n", 202 | " /* Is output safe? */\n", 203 | " safe: true,\n", 204 | " /* Index of renderer in `output_area.display_order` */\n", 205 | " index: 0\n", 206 | " });\n", 207 | " }\n", 208 | "\n", 209 | " // register the mime type if in Jupyter Notebook environment and previously unregistered\n", 210 | " if (root.Jupyter !== undefined) {\n", 211 | " var events = require('base/js/events');\n", 212 | " var OutputArea = require('notebook/js/outputarea').OutputArea;\n", 213 | "\n", 214 | " if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n", 215 | " register_renderer(events, OutputArea);\n", 216 | " }\n", 217 | " }\n", 218 | "\n", 219 | " \n", 220 | " if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n", 221 | " root._bokeh_timeout = Date.now() + 5000;\n", 222 | " root._bokeh_failed_load = false;\n", 223 | " }\n", 224 | "\n", 225 | " var NB_LOAD_WARNING = {'data': {'text/html':\n", 226 | " \"
\\n\"+\n", 227 | " \"

\\n\"+\n", 228 | " \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", 229 | " \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", 230 | " \"

\\n\"+\n", 231 | " \"\\n\"+\n", 235 | " \"\\n\"+\n", 236 | " \"from bokeh.resources import INLINE\\n\"+\n", 237 | " \"output_notebook(resources=INLINE)\\n\"+\n", 238 | " \"\\n\"+\n", 239 | " \"
\"}};\n", 240 | "\n", 241 | " function display_loaded() {\n", 242 | " var el = document.getElementById(\"1002\");\n", 243 | " if (el != null) {\n", 244 | " el.textContent = \"BokehJS is loading...\";\n", 245 | " }\n", 246 | " if (root.Bokeh !== undefined) {\n", 247 | " if (el != null) {\n", 248 | " el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n", 249 | " }\n", 250 | " } else if (Date.now() < root._bokeh_timeout) {\n", 251 | " setTimeout(display_loaded, 100)\n", 252 | " }\n", 253 | " }\n", 254 | "\n", 255 | "\n", 256 | " function run_callbacks() {\n", 257 | " try {\n", 258 | " root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n", 259 | " }\n", 260 | " finally {\n", 261 | " delete root._bokeh_onload_callbacks\n", 262 | " }\n", 263 | " console.info(\"Bokeh: all callbacks have finished\");\n", 264 | " }\n", 265 | "\n", 266 | " function load_libs(js_urls, callback) {\n", 267 | " root._bokeh_onload_callbacks.push(callback);\n", 268 | " if (root._bokeh_is_loading > 0) {\n", 269 | " console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n", 270 | " return null;\n", 271 | " }\n", 272 | " if (js_urls == null || js_urls.length === 0) {\n", 273 | " run_callbacks();\n", 274 | " return null;\n", 275 | " }\n", 276 | " console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", 277 | " root._bokeh_is_loading = js_urls.length;\n", 278 | " for (var i = 0; i < js_urls.length; i++) {\n", 279 | " var url = js_urls[i];\n", 280 | " var s = document.createElement('script');\n", 281 | " s.src = url;\n", 282 | " s.async = false;\n", 283 | " s.onreadystatechange = s.onload = function() {\n", 284 | " root._bokeh_is_loading--;\n", 285 | " if (root._bokeh_is_loading === 0) {\n", 286 | " console.log(\"Bokeh: all BokehJS libraries loaded\");\n", 287 | " run_callbacks()\n", 288 | " }\n", 289 | " };\n", 290 | " s.onerror = function() {\n", 291 | " console.warn(\"failed to load library \" + url);\n", 292 | " };\n", 293 | " console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", 294 | " document.getElementsByTagName(\"head\")[0].appendChild(s);\n", 295 | " }\n", 296 | " };var element = document.getElementById(\"1002\");\n", 297 | " if (element == null) {\n", 298 | " console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1002' but no matching script tag was found. \")\n", 299 | " return false;\n", 300 | " }\n", 301 | "\n", 302 | " var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.0.4.min.js\"];\n", 303 | "\n", 304 | " var inline_js = [\n", 305 | " function(Bokeh) {\n", 306 | " Bokeh.set_log_level(\"info\");\n", 307 | " },\n", 308 | " \n", 309 | " function(Bokeh) {\n", 310 | " \n", 311 | " },\n", 312 | " function(Bokeh) {\n", 313 | " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.css\");\n", 314 | " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.css\");\n", 315 | " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css\");\n", 316 | " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css\");\n", 317 | " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.min.css\");\n", 318 | " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.min.css\");\n", 319 | " }\n", 320 | " ];\n", 321 | "\n", 322 | " function run_inline_js() {\n", 323 | " \n", 324 | " if ((root.Bokeh !== undefined) || (force === true)) {\n", 325 | " for (var i = 0; i < inline_js.length; i++) {\n", 326 | " inline_js[i].call(root, root.Bokeh);\n", 327 | " }if (force === true) {\n", 328 | " display_loaded();\n", 329 | " }} else if (Date.now() < root._bokeh_timeout) {\n", 330 | " setTimeout(run_inline_js, 100);\n", 331 | " } else if (!root._bokeh_failed_load) {\n", 332 | " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", 333 | " root._bokeh_failed_load = true;\n", 334 | " } else if (force !== true) {\n", 335 | " var cell = $(document.getElementById(\"1002\")).parents('.cell').data().cell;\n", 336 | " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", 337 | " }\n", 338 | "\n", 339 | " }\n", 340 | "\n", 341 | " if (root._bokeh_is_loading === 0) {\n", 342 | " console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n", 343 | " run_inline_js();\n", 344 | " } else {\n", 345 | " load_libs(js_urls, function() {\n", 346 | " console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n", 347 | " run_inline_js();\n", 348 | " });\n", 349 | " }\n", 350 | "}(window));" 351 | ], 352 | "application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded() {\n var el = document.getElementById(\"1002\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n }\n finally {\n delete root._bokeh_onload_callbacks\n }\n console.info(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(js_urls, callback) {\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = js_urls.length;\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var s = document.createElement('script');\n s.src = url;\n s.async = false;\n s.onreadystatechange = s.onload = function() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: all BokehJS libraries loaded\");\n run_callbacks()\n }\n };\n s.onerror = function() {\n console.warn(\"failed to load library \" + url);\n };\n console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.getElementsByTagName(\"head\")[0].appendChild(s);\n }\n };var element = document.getElementById(\"1002\");\n if (element == null) {\n console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1002' but no matching script tag was found. \")\n return false;\n }\n\n var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.0.4.min.js\"];\n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n \n function(Bokeh) {\n \n },\n function(Bokeh) {\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.4.min.css\");\n }\n ];\n\n function run_inline_js() {\n \n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }if (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(\"1002\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(js_urls, function() {\n console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));" 353 | }, 354 | "metadata": {}, 355 | "output_type": "display_data" 356 | } 357 | ], 358 | "source": [ 359 | "import pandas as pd\n", 360 | "from bokeh.plotting import figure, output_file, show,output_notebook\n", 361 | "output_notebook()" 362 | ] 363 | }, 364 | { 365 | "cell_type": "markdown", 366 | "metadata": {}, 367 | "source": [ 368 | "In this section, we define the function make_dashboard." 369 | ] 370 | }, 371 | { 372 | "cell_type": "code", 373 | "execution_count": 3, 374 | "metadata": {}, 375 | "outputs": [], 376 | "source": [ 377 | "def make_dashboard(x, gdp_change, unemployment, title, file_name):\n", 378 | " output_file(file_name)\n", 379 | " p = figure(title=title, x_axis_label='year', y_axis_label='%')\n", 380 | " p.line(x.squeeze(), gdp_change.squeeze(), color=\"darkgreen\", line_width=4, legend=\"% change in GDP \")\n", 381 | " p.line(x.squeeze(), unemployment.squeeze(), color=\"crimson\", line_width=4, legend=\"% unemployed\")\n", 382 | " show(p)" 383 | ] 384 | }, 385 | { 386 | "cell_type": "markdown", 387 | "metadata": {}, 388 | "source": [ 389 | "The dictionary links contain the CSV files with all the data. The value for the key GDP is the file that contains the GDP data. The value for the key unemployment contains the unemployment data." 390 | ] 391 | }, 392 | { 393 | "cell_type": "code", 394 | "execution_count": 4, 395 | "metadata": {}, 396 | "outputs": [], 397 | "source": [ 398 | "links={'GDP':'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_gdp.csv',\\\n", 399 | " 'unemployment':'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_unemployment.csv'}" 400 | ] 401 | }, 402 | { 403 | "cell_type": "markdown", 404 | "metadata": {}, 405 | "source": [ 406 | "

Question 1: Create a dataframe that contains the GDP data and display the first five rows of the dataframe.

" 407 | ] 408 | }, 409 | { 410 | "cell_type": "markdown", 411 | "metadata": {}, 412 | "source": [ 413 | "Use the dictionary links to create a Pandas dataframes that contains the GDP data." 414 | ] 415 | }, 416 | { 417 | "cell_type": "code", 418 | "execution_count": 5, 419 | "metadata": {}, 420 | "outputs": [], 421 | "source": [ 422 | "gdp_df = pd.read_csv(links[\"GDP\"]) # \"current\" is a nominal GDP and \"chained\" is a real GDP" 423 | ] 424 | }, 425 | { 426 | "cell_type": "markdown", 427 | "metadata": {}, 428 | "source": [ 429 | "Display the first five rows of the GDP data." 430 | ] 431 | }, 432 | { 433 | "cell_type": "code", 434 | "execution_count": 6, 435 | "metadata": {}, 436 | "outputs": [ 437 | { 438 | "data": { 439 | "text/html": [ 440 | "
\n", 441 | "\n", 454 | "\n", 455 | " \n", 456 | " \n", 457 | " \n", 458 | " \n", 459 | " \n", 460 | " \n", 461 | " \n", 462 | " \n", 463 | " \n", 464 | " \n", 465 | " \n", 466 | " \n", 467 | " \n", 468 | " \n", 469 | " \n", 470 | " \n", 471 | " \n", 472 | " \n", 473 | " \n", 474 | " \n", 475 | " \n", 476 | " \n", 477 | " \n", 478 | " \n", 479 | " \n", 480 | " \n", 481 | " \n", 482 | " \n", 483 | " \n", 484 | " \n", 485 | " \n", 486 | " \n", 487 | " \n", 488 | " \n", 489 | " \n", 490 | " \n", 491 | " \n", 492 | " \n", 493 | " \n", 494 | " \n", 495 | " \n", 496 | " \n", 497 | " \n", 498 | " \n", 499 | " \n", 500 | " \n", 501 | " \n", 502 | " \n", 503 | " \n", 504 | " \n", 505 | " \n", 506 | " \n", 507 | "
datelevel-currentlevel-chainedchange-currentchange-chained
01948274.82020.0-0.7-0.6
11949272.82008.910.08.7
21950300.22184.015.78.0
31951347.32360.05.94.1
41952367.72456.16.04.7
\n", 508 | "
" 509 | ], 510 | "text/plain": [ 511 | " date level-current level-chained change-current change-chained\n", 512 | "0 1948 274.8 2020.0 -0.7 -0.6\n", 513 | "1 1949 272.8 2008.9 10.0 8.7\n", 514 | "2 1950 300.2 2184.0 15.7 8.0\n", 515 | "3 1951 347.3 2360.0 5.9 4.1\n", 516 | "4 1952 367.7 2456.1 6.0 4.7" 517 | ] 518 | }, 519 | "execution_count": 6, 520 | "metadata": {}, 521 | "output_type": "execute_result" 522 | } 523 | ], 524 | "source": [ 525 | "gdp_df.head() # The first five rows of the GDP Data, starting from the year 1948" 526 | ] 527 | }, 528 | { 529 | "cell_type": "markdown", 530 | "metadata": {}, 531 | "source": [ 532 | "

Question 2: Create a dataframe that contains the unemployment data. Display the first five rows of the dataframe.

" 533 | ] 534 | }, 535 | { 536 | "cell_type": "markdown", 537 | "metadata": {}, 538 | "source": [ 539 | "Use the dictionary links to create a Pandas dataframes that contains the unemployment data." 540 | ] 541 | }, 542 | { 543 | "cell_type": "code", 544 | "execution_count": 7, 545 | "metadata": {}, 546 | "outputs": [], 547 | "source": [ 548 | "u_df = pd.read_csv(links[\"unemployment\"]) # this is given as a percentage" 549 | ] 550 | }, 551 | { 552 | "cell_type": "markdown", 553 | "metadata": {}, 554 | "source": [ 555 | "Display the first five rows of the GDP data." 556 | ] 557 | }, 558 | { 559 | "cell_type": "code", 560 | "execution_count": 8, 561 | "metadata": {}, 562 | "outputs": [ 563 | { 564 | "data": { 565 | "text/html": [ 566 | "
\n", 567 | "\n", 580 | "\n", 581 | " \n", 582 | " \n", 583 | " \n", 584 | " \n", 585 | " \n", 586 | " \n", 587 | " \n", 588 | " \n", 589 | " \n", 590 | " \n", 591 | " \n", 592 | " \n", 593 | " \n", 594 | " \n", 595 | " \n", 596 | " \n", 597 | " \n", 598 | " \n", 599 | " \n", 600 | " \n", 601 | " \n", 602 | " \n", 603 | " \n", 604 | " \n", 605 | " \n", 606 | " \n", 607 | " \n", 608 | " \n", 609 | " \n", 610 | " \n", 611 | " \n", 612 | " \n", 613 | " \n", 614 | " \n", 615 | "
dateunemployment
019483.750000
119496.050000
219505.208333
319513.283333
419523.025000
\n", 616 | "
" 617 | ], 618 | "text/plain": [ 619 | " date unemployment\n", 620 | "0 1948 3.750000\n", 621 | "1 1949 6.050000\n", 622 | "2 1950 5.208333\n", 623 | "3 1951 3.283333\n", 624 | "4 1952 3.025000" 625 | ] 626 | }, 627 | "execution_count": 8, 628 | "metadata": {}, 629 | "output_type": "execute_result" 630 | } 631 | ], 632 | "source": [ 633 | "u_df.head() # the first five rows of the unemployment rate in the U.S." 634 | ] 635 | }, 636 | { 637 | "cell_type": "markdown", 638 | "metadata": {}, 639 | "source": [ 640 | "

Question 3: Display a dataframe where unemployment was greater than 8.5%." 641 | ] 642 | }, 643 | { 644 | "cell_type": "code", 645 | "execution_count": 9, 646 | "metadata": {}, 647 | "outputs": [ 648 | { 649 | "data": { 650 | "text/html": [ 651 | "
\n", 652 | "\n", 665 | "\n", 666 | " \n", 667 | " \n", 668 | " \n", 669 | " \n", 670 | " \n", 671 | " \n", 672 | " \n", 673 | " \n", 674 | " \n", 675 | " \n", 676 | " \n", 677 | " \n", 678 | " \n", 679 | " \n", 680 | " \n", 681 | " \n", 682 | " \n", 683 | " \n", 684 | " \n", 685 | " \n", 686 | " \n", 687 | " \n", 688 | " \n", 689 | " \n", 690 | " \n", 691 | " \n", 692 | " \n", 693 | " \n", 694 | " \n", 695 | " \n", 696 | " \n", 697 | " \n", 698 | " \n", 699 | " \n", 700 | "
dateunemployment
3419829.708333
3519839.600000
6120099.283333
6220109.608333
6320118.933333
\n", 701 | "
" 702 | ], 703 | "text/plain": [ 704 | " date unemployment\n", 705 | "34 1982 9.708333\n", 706 | "35 1983 9.600000\n", 707 | "61 2009 9.283333\n", 708 | "62 2010 9.608333\n", 709 | "63 2011 8.933333" 710 | ] 711 | }, 712 | "execution_count": 9, 713 | "metadata": {}, 714 | "output_type": "execute_result" 715 | } 716 | ], 717 | "source": [ 718 | "u_over85_df = u_df[u_df['unemployment'] >= 8.5] # Years when unemployment rate was more than 8.5%\n", 719 | "\n", 720 | "u_over85_df.to_csv('u_over8perc.csv') # saved this data as a new CSV file\n", 721 | "\n", 722 | "u_over85_df" 723 | ] 724 | }, 725 | { 726 | "cell_type": "markdown", 727 | "metadata": {}, 728 | "source": [ 729 | "

Question 4: Use the function make_dashboard to make a dashboard

" 730 | ] 731 | }, 732 | { 733 | "cell_type": "markdown", 734 | "metadata": {}, 735 | "source": [ 736 | "In this section, you will call the function make_dashboard , to produce a dashboard. We will use the convention of giving each variable the same name as the function parameter." 737 | ] 738 | }, 739 | { 740 | "cell_type": "markdown", 741 | "metadata": {}, 742 | "source": [ 743 | "Create a new dataframe with the column 'date' called x from the dataframe that contains the GDP data." 744 | ] 745 | }, 746 | { 747 | "cell_type": "code", 748 | "execution_count": 10, 749 | "metadata": { 750 | "scrolled": true 751 | }, 752 | "outputs": [ 753 | { 754 | "data": { 755 | "text/plain": [ 756 | "0 1948\n", 757 | "1 1949\n", 758 | "2 1950\n", 759 | "3 1951\n", 760 | "4 1952\n", 761 | "Name: date, dtype: int64" 762 | ] 763 | }, 764 | "execution_count": 10, 765 | "metadata": {}, 766 | "output_type": "execute_result" 767 | } 768 | ], 769 | "source": [ 770 | "x = gdp_df['date'] # dataframe which contains dates from GDP 'data'\n", 771 | "x.head()" 772 | ] 773 | }, 774 | { 775 | "cell_type": "markdown", 776 | "metadata": {}, 777 | "source": [ 778 | "Create a new dataframe with the column 'change-current' called gdp_change from the dataframe that contains the GDP data." 779 | ] 780 | }, 781 | { 782 | "cell_type": "code", 783 | "execution_count": 11, 784 | "metadata": {}, 785 | "outputs": [ 786 | { 787 | "data": { 788 | "text/plain": [ 789 | "0 -0.7\n", 790 | "1 10.0\n", 791 | "2 15.7\n", 792 | "3 5.9\n", 793 | "4 6.0\n", 794 | "Name: change-current, dtype: float64" 795 | ] 796 | }, 797 | "execution_count": 11, 798 | "metadata": {}, 799 | "output_type": "execute_result" 800 | } 801 | ], 802 | "source": [ 803 | "gdp_change = gdp_df['change-current'] # new dataframe with column 'change-current'\n", 804 | "gdp_change.head()" 805 | ] 806 | }, 807 | { 808 | "cell_type": "markdown", 809 | "metadata": {}, 810 | "source": [ 811 | "Create a new dataframe with the column 'unemployment' called unemployment from the dataframe that contains the unemployment data." 812 | ] 813 | }, 814 | { 815 | "cell_type": "code", 816 | "execution_count": 19, 817 | "metadata": {}, 818 | "outputs": [ 819 | { 820 | "data": { 821 | "text/plain": [ 822 | "0 3.75\n", 823 | "1 6.05\n", 824 | "2 5.21\n", 825 | "3 3.28\n", 826 | "4 3.03\n", 827 | "Name: unemployment, dtype: float64" 828 | ] 829 | }, 830 | "execution_count": 19, 831 | "metadata": {}, 832 | "output_type": "execute_result" 833 | } 834 | ], 835 | "source": [ 836 | "unemployment = round(u_df['unemployment'], 2) # dataframe with column unemployment from GDP data\n", 837 | "unemployment.head()" 838 | ] 839 | }, 840 | { 841 | "cell_type": "markdown", 842 | "metadata": {}, 843 | "source": [ 844 | "Give your dashboard a string title, and assign it to the variable title" 845 | ] 846 | }, 847 | { 848 | "cell_type": "code", 849 | "execution_count": 13, 850 | "metadata": {}, 851 | "outputs": [ 852 | { 853 | "name": "stdout", 854 | "output_type": "stream", 855 | "text": [ 856 | "*** U.S. Economy Analysis ***\n" 857 | ] 858 | } 859 | ], 860 | "source": [ 861 | "title = '*** U.S. Economy Analysis ***' # Give your dashboard a string title\n", 862 | "print(title)" 863 | ] 864 | }, 865 | { 866 | "cell_type": "markdown", 867 | "metadata": {}, 868 | "source": [ 869 | "Finally, the function make_dashboard will output an .html in your direictory, just like a csv file. The name of the file is \"index.html\" and it will be stored in the varable file_name." 870 | ] 871 | }, 872 | { 873 | "cell_type": "code", 874 | "execution_count": 20, 875 | "metadata": {}, 876 | "outputs": [], 877 | "source": [ 878 | "file_name = \"index.html\"" 879 | ] 880 | }, 881 | { 882 | "cell_type": "markdown", 883 | "metadata": {}, 884 | "source": [ 885 | "Call the function make_dashboard , to produce a dashboard. Assign the parameter values accordingly." 886 | ] 887 | }, 888 | { 889 | "cell_type": "code", 890 | "execution_count": 21, 891 | "metadata": {}, 892 | "outputs": [ 893 | { 894 | "data": { 895 | "text/html": [ 896 | "\n", 897 | "\n", 898 | "\n", 899 | "\n", 900 | "\n", 901 | "\n", 902 | "
\n" 903 | ] 904 | }, 905 | "metadata": {}, 906 | "output_type": "display_data" 907 | }, 908 | { 909 | "data": { 910 | "application/javascript": [ 911 | "(function(root) {\n", 912 | " function embed_document(root) {\n", 913 | " \n", 914 | " var docs_json = {\"95fcdc54-46c6-4a9f-afef-7cdf5304e243\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1218\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"1223\",\"type\":\"LinearAxis\"}],\"renderers\":[{\"id\":\"1218\",\"type\":\"LinearAxis\"},{\"id\":\"1222\",\"type\":\"Grid\"},{\"id\":\"1223\",\"type\":\"LinearAxis\"},{\"id\":\"1227\",\"type\":\"Grid\"},{\"id\":\"1236\",\"type\":\"BoxAnnotation\"},{\"id\":\"1254\",\"type\":\"Legend\"},{\"id\":\"1246\",\"type\":\"GlyphRenderer\"},{\"id\":\"1259\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"1207\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"1234\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"1210\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"1214\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"1212\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"1216\",\"type\":\"LinearScale\"}},\"id\":\"1208\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"callback\":null},\"id\":\"1210\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1232\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"1267\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"callback\":null},\"id\":\"1212\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1233\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"1216\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1268\",\"type\":\"Selection\"},{\"attributes\":{\"line_color\":\"darkgreen\",\"line_width\":4,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1244\",\"type\":\"Line\"},{\"attributes\":{\"label\":{\"value\":\"% unemployed\"},\"renderers\":[{\"id\":\"1259\",\"type\":\"GlyphRenderer\"}]},\"id\":\"1269\",\"type\":\"LegendItem\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1228\",\"type\":\"PanTool\"},{\"id\":\"1229\",\"type\":\"WheelZoomTool\"},{\"id\":\"1230\",\"type\":\"BoxZoomTool\"},{\"id\":\"1231\",\"type\":\"SaveTool\"},{\"id\":\"1232\",\"type\":\"ResetTool\"},{\"id\":\"1233\",\"type\":\"HelpTool\"}]},\"id\":\"1234\",\"type\":\"Toolbar\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1236\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"plot\":{\"id\":\"1208\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1219\",\"type\":\"BasicTicker\"}},\"id\":\"1222\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1219\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1288\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"axis_label\":\"year\",\"formatter\":{\"id\":\"1250\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"1208\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1219\",\"type\":\"BasicTicker\"}},\"id\":\"1218\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null,\"data\":{\"x\":[1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016],\"y\":{\"__ndarray__\":\"ZmZmZmZm5r8AAAAAAAAkQGZmZmZmZi9AmpmZmZmZF0AAAAAAAAAYQDMzMzMzM9M/zczMzMzMIUBmZmZmZmYWQAAAAAAAABZAAAAAAAAA+D/NzMzMzMwgQAAAAAAAABBAmpmZmZmZDUCamZmZmZkdQGZmZmZmZhZAmpmZmZmZHUDNzMzMzMwgQDMzMzMzMyNAzczMzMzMFkDNzMzMzMwiQGZmZmZmZiBAAAAAAAAAFkAAAAAAAAAhQJqZmZmZmSNAzczMzMzMJkDNzMzMzMwgQAAAAAAAACJAZmZmZmZmJkAzMzMzMzMmQAAAAAAAACpAZmZmZmZmJ0CamZmZmZkhQGZmZmZmZihAMzMzMzMzEUBmZmZmZmYhQDMzMzMzMyZAAAAAAAAAHkAAAAAAAAAWQAAAAAAAABhAmpmZmZmZH0DNzMzMzMweQM3MzMzMzBZAZmZmZmZmCkCamZmZmZkXQM3MzMzMzBRAMzMzMzMzGUAzMzMzMzMTQM3MzMzMzBZAzczMzMzMGEDNzMzMzMwWQDMzMzMzMxlAAAAAAAAAGkCamZmZmZkJQDMzMzMzMwtAMzMzMzMzE0BmZmZmZmYaQM3MzMzMzBpAAAAAAAAAGEBmZmZmZmYSQM3MzMzMzPw/zczMzMzM/L9mZmZmZmYOQJqZmZmZmQ1AzczMzMzMEEDNzMzMzMwMQJqZmZmZmRFAAAAAAAAAEECamZmZmZkFQM3MzMzMzBBA\",\"dtype\":\"float64\",\"shape\":[69]}},\"selected\":{\"id\":\"1268\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"1267\",\"type\":\"UnionRenderers\"}},\"id\":\"1243\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"line_width\":4,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1245\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1289\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1214\",\"type\":\"LinearScale\"},{\"attributes\":{\"source\":{\"id\":\"1243\",\"type\":\"ColumnDataSource\"}},\"id\":\"1247\",\"type\":\"CDSView\"},{\"attributes\":{\"axis_label\":\"%\",\"formatter\":{\"id\":\"1252\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"1208\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1224\",\"type\":\"BasicTicker\"}},\"id\":\"1223\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1250\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"1224\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1252\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"1208\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1224\",\"type\":\"BasicTicker\"}},\"id\":\"1227\",\"type\":\"Grid\"},{\"attributes\":{\"items\":[{\"id\":\"1255\",\"type\":\"LegendItem\"},{\"id\":\"1269\",\"type\":\"LegendItem\"}],\"plot\":{\"id\":\"1208\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"1254\",\"type\":\"Legend\"},{\"attributes\":{\"label\":{\"value\":\"% change in GDP \"},\"renderers\":[{\"id\":\"1246\",\"type\":\"GlyphRenderer\"}]},\"id\":\"1255\",\"type\":\"LegendItem\"},{\"attributes\":{\"data_source\":{\"id\":\"1243\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"1244\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1245\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"1247\",\"type\":\"CDSView\"}},\"id\":\"1246\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"callback\":null,\"data\":{\"x\":[1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016],\"y\":{\"__ndarray__\":\"AAAAAAAADkAzMzMzMzMYQNejcD0K1xRAPQrXo3A9CkA9CtejcD0IQFyPwvUoXAdAXI/C9ShcFkB7FK5H4XoRQHsUrkfhehBAMzMzMzMzEUBcj8L1KFwbQM3MzMzMzBVAKVyPwvUoFkDD9Shcj8IaQEjhehSuRxZAj8L1KFyPFkCkcD0K16MUQArXo3A9ChJAUrgehetRDkC4HoXrUbgOQHsUrkfhegxA7FG4HoXrC0DsUbgehesTQM3MzMzMzBdAZmZmZmZmFkBxPQrXo3ATQI/C9ShcjxZA9ihcj8L1IEDNzMzMzMweQDMzMzMzMxxASOF6FK5HGEBmZmZmZmYXQLgehetRuBxAexSuR+F6HkDsUbgehWsjQDMzMzMzMyNACtejcD0KHkDD9Shcj8IcQAAAAAAAABxAuB6F61G4GED2KFyPwvUVQArXo3A9ChVAexSuR+F6FkBmZmZmZmYbQPYoXI/C9R1ApHA9CtejG0BmZmZmZmYYQFyPwvUoXBZApHA9CtejFUDD9Shcj8ITQAAAAAAAABJA4XoUrkfhEEDD9Shcj8IPQPYoXI/C9RJAH4XrUbgeF0D2KFyPwvUXQClcj8L1KBZAUrgehetRFEBxPQrXo3ASQHsUrkfhehJAMzMzMzMzF0CPwvUoXI8iQLgehetROCNAXI/C9SjcIUApXI/C9SggQHE9CtejcB1ApHA9CtejGEAfhetRuB4VQIXrUbgehRNA\",\"dtype\":\"float64\",\"shape\":[69]}},\"selected\":{\"id\":\"1289\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"1288\",\"type\":\"UnionRenderers\"}},\"id\":\"1256\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1228\",\"type\":\"PanTool\"},{\"attributes\":{\"line_color\":\"crimson\",\"line_width\":4,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1257\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"1229\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"line_width\":4,\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1258\",\"type\":\"Line\"},{\"attributes\":{\"overlay\":{\"id\":\"1236\",\"type\":\"BoxAnnotation\"}},\"id\":\"1230\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"plot\":null,\"text\":\"*** U.S. Economy Analysis ***\"},\"id\":\"1207\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"1231\",\"type\":\"SaveTool\"},{\"attributes\":{\"data_source\":{\"id\":\"1256\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"1257\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1258\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"1260\",\"type\":\"CDSView\"}},\"id\":\"1259\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"source\":{\"id\":\"1256\",\"type\":\"ColumnDataSource\"}},\"id\":\"1260\",\"type\":\"CDSView\"}],\"root_ids\":[\"1208\"]},\"title\":\"Bokeh Application\",\"version\":\"1.0.4\"}};\n", 915 | " var render_items = [{\"docid\":\"95fcdc54-46c6-4a9f-afef-7cdf5304e243\",\"roots\":{\"1208\":\"b7079136-a21b-45f0-85f0-82b7443fe3ff\"}}];\n", 916 | " root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n", 917 | "\n", 918 | " }\n", 919 | " if (root.Bokeh !== undefined) {\n", 920 | " embed_document(root);\n", 921 | " } else {\n", 922 | " var attempts = 0;\n", 923 | " var timer = setInterval(function(root) {\n", 924 | " if (root.Bokeh !== undefined) {\n", 925 | " embed_document(root);\n", 926 | " clearInterval(timer);\n", 927 | " }\n", 928 | " attempts++;\n", 929 | " if (attempts > 100) {\n", 930 | " console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n", 931 | " clearInterval(timer);\n", 932 | " }\n", 933 | " }, 10, root)\n", 934 | " }\n", 935 | "})(window);" 936 | ], 937 | "application/vnd.bokehjs_exec.v0+json": "" 938 | }, 939 | "metadata": { 940 | "application/vnd.bokehjs_exec.v0+json": { 941 | "id": "1208" 942 | } 943 | }, 944 | "output_type": "display_data" 945 | } 946 | ], 947 | "source": [ 948 | "# Fill up the parameters in the following function:\n", 949 | "# make_dashboard(x=, gdp_change=, unemployment=, title=, file_name=)\n", 950 | "\n", 951 | "make_dashboard(x, gdp_change, unemployment, title, file_name)" 952 | ] 953 | }, 954 | { 955 | "cell_type": "markdown", 956 | "metadata": {}, 957 | "source": [ 958 | "

How to submit

" 959 | ] 960 | }, 961 | { 962 | "cell_type": "markdown", 963 | "metadata": {}, 964 | "source": [ 965 | "

Once you complete your notebook you will have to share it to be marked. Select the icon on the top right a marked in red in the image below, a dialogue box should open, select the option all content excluding sensitive code cells.

\n", 966 | "\n", 967 | "

\"share

\n", 968 | "

\n", 969 | "\n", 970 | "

You can then share the notebook  via a  URL by scrolling down as shown in the following image:

\n", 971 | "

\"share

" 972 | ] 973 | }, 974 | { 975 | "cell_type": "markdown", 976 | "metadata": {}, 977 | "source": [ 978 | "
\n", 979 | "

Copyright © 2019 IBM Developer Skills Network. This notebook and its source code are released under the terms of the MIT License.

" 980 | ] 981 | }, 982 | { 983 | "cell_type": "markdown", 984 | "metadata": {}, 985 | "source": [ 986 | "

About the Authors:

\n", 987 | "\n", 988 | "Joseph Santarcangelo has a PhD in Electrical Engineering, his research focused on using machine learning, signal processing, and computer vision to determine how videos impact human cognition. Joseph has been working for IBM since he completed his PhD.\n", 989 | "

\n", 990 | "Other contributors: Yi leng Yao, Mavis Zhou \n", 991 | "

" 992 | ] 993 | }, 994 | { 995 | "cell_type": "markdown", 996 | "metadata": {}, 997 | "source": [ 998 | "

References :

" 999 | ] 1000 | }, 1001 | { 1002 | "cell_type": "markdown", 1003 | "metadata": {}, 1004 | "source": [ 1005 | "\n", 1017 | "" 1018 | ] 1019 | } 1020 | ], 1021 | "metadata": { 1022 | "kernelspec": { 1023 | "display_name": "Python 3.6", 1024 | "language": "python", 1025 | "name": "python3" 1026 | }, 1027 | "language_info": { 1028 | "codemirror_mode": { 1029 | "name": "ipython", 1030 | "version": 3 1031 | }, 1032 | "file_extension": ".py", 1033 | "mimetype": "text/x-python", 1034 | "name": "python", 1035 | "nbconvert_exporter": "python", 1036 | "pygments_lexer": "ipython3", 1037 | "version": "3.6.8" 1038 | } 1039 | }, 1040 | "nbformat": 4, 1041 | "nbformat_minor": 2 1042 | } 1043 | -------------------------------------------------------------------------------- /running_sql_db.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "

Assignment: Notebook for Peer Assignment

" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "# Introduction\n", 17 | "\n", 18 | "Using this Python notebook you will:\n", 19 | "1. Understand 3 Chicago datasets \n", 20 | "1. Load the 3 datasets into 3 tables in a Db2 database\n", 21 | "1. Execute SQL queries to answer assignment questions " 22 | ] 23 | }, 24 | { 25 | "cell_type": "markdown", 26 | "metadata": {}, 27 | "source": [ 28 | "## Understand the datasets \n", 29 | "To complete the assignment problems in this notebook you will be using three datasets that are available on the city of Chicago's Data Portal:\n", 30 | "1. Socioeconomic Indicators in Chicago\n", 31 | "1. Chicago Public Schools\n", 32 | "1. Chicago Crime Data\n", 33 | "\n", 34 | "### 1. Socioeconomic Indicators in Chicago\n", 35 | "This dataset contains a selection of six socioeconomic indicators of public health significance and a “hardship index,” for each Chicago community area, for the years 2008 – 2012.\n", 36 | "\n", 37 | "For this assignment you will use a snapshot of this dataset which can be downloaded from:\n", 38 | "https://ibm.box.com/shared/static/05c3415cbfbtfnr2fx4atenb2sd361ze.csv\n", 39 | "\n", 40 | "A detailed description of this dataset and the original dataset can be obtained from the Chicago Data Portal at:\n", 41 | "https://data.cityofchicago.org/Health-Human-Services/Census-Data-Selected-socioeconomic-indicators-in-C/kn9c-c2s2\n", 42 | "\n", 43 | "\n", 44 | "\n", 45 | "### 2. Chicago Public Schools\n", 46 | "\n", 47 | "This dataset shows all school level performance data used to create CPS School Report Cards for the 2011-2012 school year. This dataset is provided by the city of Chicago's Data Portal.\n", 48 | "\n", 49 | "For this assignment you will use a snapshot of this dataset which can be downloaded from:\n", 50 | "https://ibm.box.com/shared/static/f9gjvj1gjmxxzycdhplzt01qtz0s7ew7.csv\n", 51 | "\n", 52 | "A detailed description of this dataset and the original dataset can be obtained from the Chicago Data Portal at:\n", 53 | "https://data.cityofchicago.org/Education/Chicago-Public-Schools-Progress-Report-Cards-2011-/9xs2-f89t\n", 54 | "\n", 55 | "\n", 56 | "\n", 57 | "\n", 58 | "### 3. Chicago Crime Data \n", 59 | "\n", 60 | "This dataset reflects reported incidents of crime (with the exception of murders where data exists for each victim) that occurred in the City of Chicago from 2001 to present, minus the most recent seven days. \n", 61 | "\n", 62 | "This dataset is quite large - over 1.5GB in size with over 6.5 million rows. For the purposes of this assignment we will use a much smaller sample of this dataset which can be downloaded from:\n", 63 | "https://ibm.box.com/shared/static/svflyugsr9zbqy5bmowgswqemfpm1x7f.csv\n", 64 | "\n", 65 | "A detailed description of this dataset and the original dataset can be obtained from the Chicago Data Portal at:\n", 66 | "https://data.cityofchicago.org/Public-Safety/Crimes-2001-to-present/ijzp-q8t2\n" 67 | ] 68 | }, 69 | { 70 | "cell_type": "markdown", 71 | "metadata": {}, 72 | "source": [ 73 | "### Download the datasets\n", 74 | "In many cases the dataset to be analyzed is available as a .CSV (comma separated values) file, perhaps on the internet. Click on the links below to download and save the datasets (.CSV files):\n", 75 | "1. __CENSUS_DATA:__ https://ibm.box.com/shared/static/05c3415cbfbtfnr2fx4atenb2sd361ze.csv\n", 76 | "1. __CHICAGO_PUBLIC_SCHOOLS__ https://ibm.box.com/shared/static/f9gjvj1gjmxxzycdhplzt01qtz0s7ew7.csv\n", 77 | "1. __CHICAGO_CRIME_DATA:__ https://ibm.box.com/shared/static/svflyugsr9zbqy5bmowgswqemfpm1x7f.csv\n", 78 | "\n", 79 | "__NOTE:__ Ensure you have downloaded the datasets using the links above instead of directly from the Chicago Data Portal. The versions linked here are subsets of the original datasets and have some of the column names modified to be more database friendly which will make it easier to complete this assignment." 80 | ] 81 | }, 82 | { 83 | "cell_type": "markdown", 84 | "metadata": {}, 85 | "source": [ 86 | "### Store the datasets in database tables\n", 87 | "To analyze the data using SQL, it first needs to be stored in the database.\n", 88 | "\n", 89 | "While it is easier to read the dataset into a Pandas dataframe and then PERSIST it into the database as we saw in Week 3 Lab 3, it results in mapping to default datatypes which may not be optimal for SQL querying. For example a long textual field may map to a CLOB instead of a VARCHAR. \n", 90 | "\n", 91 | "Therefore, __it is highly recommended to manually load the table using the database console LOAD tool, as indicated in Week 2 Lab 1 Part II__. The only difference with that lab is that in Step 5 of the instructions you will need to click on create \"(+) New Table\" and specify the name of the table you want to create and then click \"Next\". \n", 92 | "\n", 93 | "\n", 94 | "\n", 95 | "##### Now open the Db2 console, open the LOAD tool, Select / Drag the .CSV file for the first dataset, Next create a New Table, and then follow the steps on-screen instructions to load the data. Name the new tables as folows:\n", 96 | "1. __CENSUS_DATA__\n", 97 | "1. __CHICAGO_PUBLIC_SCHOOLS__\n", 98 | "1. __CHICAGO_CRIME_DATA__" 99 | ] 100 | }, 101 | { 102 | "cell_type": "markdown", 103 | "metadata": {}, 104 | "source": [ 105 | "### Connect to the database \n", 106 | "Let us first load the SQL extension and establish a connection with the database" 107 | ] 108 | }, 109 | { 110 | "cell_type": "code", 111 | "execution_count": 1, 112 | "metadata": {}, 113 | "outputs": [], 114 | "source": [ 115 | "%load_ext sql" 116 | ] 117 | }, 118 | { 119 | "cell_type": "markdown", 120 | "metadata": {}, 121 | "source": [ 122 | "In the next cell enter your db2 connection string. Recall you created Service Credentials for your Db2 instance in first lab in Week 3. From the __uri__ field of your Db2 service credentials copy everything after db2:// (except the double quote at the end) and paste it in the cell below after ibm_db_sa://\n", 123 | "\n", 124 | "" 125 | ] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "execution_count": 2, 130 | "metadata": {}, 131 | "outputs": [ 132 | { 133 | "data": { 134 | "text/plain": [ 135 | "'Connected: tnx67692@BLUDB'" 136 | ] 137 | }, 138 | "execution_count": 2, 139 | "metadata": {}, 140 | "output_type": "execute_result" 141 | } 142 | ], 143 | "source": [ 144 | "# Remember the connection string is of the format:\n", 145 | "# %sql ibm_db_sa://my-username:my-password@my-hostname:my-port/my-db-name\n", 146 | "# Enter the connection string for your Db2 on Cloud database instance below\n", 147 | "%sql ibm_db_sa://tnx67692:03p3756+ntd6sgr9@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB" 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "metadata": {}, 153 | "source": [ 154 | "## Problems\n", 155 | "Now write and execute SQL queries to solve assignment problems\n", 156 | "\n", 157 | "### Problem 1\n", 158 | "\n", 159 | "##### Find the total number of crimes recorded in the CRIME table" 160 | ] 161 | }, 162 | { 163 | "cell_type": "code", 164 | "execution_count": 3, 165 | "metadata": {}, 166 | "outputs": [ 167 | { 168 | "name": "stdout", 169 | "output_type": "stream", 170 | "text": [ 171 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 172 | "Done.\n" 173 | ] 174 | }, 175 | { 176 | "data": { 177 | "text/html": [ 178 | "\n", 179 | " \n", 180 | " \n", 181 | " \n", 182 | " \n", 183 | " \n", 184 | " \n", 185 | "
1
533
" 186 | ], 187 | "text/plain": [ 188 | "[(Decimal('533'),)]" 189 | ] 190 | }, 191 | "execution_count": 3, 192 | "metadata": {}, 193 | "output_type": "execute_result" 194 | } 195 | ], 196 | "source": [ 197 | "# Rows in Crime table\n", 198 | "%sql select count(*) from CHICAGO_CRIME_DATA" 199 | ] 200 | }, 201 | { 202 | "cell_type": "markdown", 203 | "metadata": {}, 204 | "source": [ 205 | "### Problem 2\n", 206 | "\n", 207 | "##### Retrieve first 10 rows from the CRIME table\n" 208 | ] 209 | }, 210 | { 211 | "cell_type": "code", 212 | "execution_count": 4, 213 | "metadata": {}, 214 | "outputs": [ 215 | { 216 | "name": "stdout", 217 | "output_type": "stream", 218 | "text": [ 219 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 220 | "Done.\n" 221 | ] 222 | }, 223 | { 224 | "data": { 225 | "text/html": [ 226 | "\n", 227 | " \n", 228 | " \n", 229 | " \n", 230 | " \n", 231 | " \n", 232 | " \n", 233 | " \n", 234 | " \n", 235 | " \n", 236 | " \n", 237 | " \n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | " \n", 243 | " \n", 244 | " \n", 245 | " \n", 246 | " \n", 247 | " \n", 248 | " \n", 249 | " \n", 250 | " \n", 251 | " \n", 252 | " \n", 253 | " \n", 254 | " \n", 255 | " \n", 256 | " \n", 257 | " \n", 258 | " \n", 259 | " \n", 260 | " \n", 261 | " \n", 262 | " \n", 263 | " \n", 264 | " \n", 265 | " \n", 266 | " \n", 267 | " \n", 268 | " \n", 269 | " \n", 270 | " \n", 271 | " \n", 272 | " \n", 273 | " \n", 274 | " \n", 275 | " \n", 276 | " \n", 277 | " \n", 278 | " \n", 279 | " \n", 280 | " \n", 281 | " \n", 282 | " \n", 283 | " \n", 284 | " \n", 285 | " \n", 286 | " \n", 287 | " \n", 288 | " \n", 289 | " \n", 290 | " \n", 291 | " \n", 292 | " \n", 293 | " \n", 294 | " \n", 295 | " \n", 296 | " \n", 297 | " \n", 298 | " \n", 299 | " \n", 300 | " \n", 301 | " \n", 302 | " \n", 303 | " \n", 304 | " \n", 305 | " \n", 306 | " \n", 307 | " \n", 308 | " \n", 309 | " \n", 310 | " \n", 311 | " \n", 312 | " \n", 313 | " \n", 314 | " \n", 315 | " \n", 316 | " \n", 317 | " \n", 318 | " \n", 319 | " \n", 320 | " \n", 321 | " \n", 322 | " \n", 323 | " \n", 324 | " \n", 325 | " \n", 326 | " \n", 327 | " \n", 328 | " \n", 329 | " \n", 330 | " \n", 331 | " \n", 332 | " \n", 333 | " \n", 334 | " \n", 335 | " \n", 336 | " \n", 337 | " \n", 338 | " \n", 339 | " \n", 340 | " \n", 341 | " \n", 342 | " \n", 343 | " \n", 344 | " \n", 345 | " \n", 346 | " \n", 347 | " \n", 348 | " \n", 349 | " \n", 350 | " \n", 351 | " \n", 352 | " \n", 353 | " \n", 354 | " \n", 355 | " \n", 356 | " \n", 357 | " \n", 358 | " \n", 359 | " \n", 360 | " \n", 361 | " \n", 362 | " \n", 363 | " \n", 364 | " \n", 365 | " \n", 366 | " \n", 367 | " \n", 368 | " \n", 369 | " \n", 370 | " \n", 371 | " \n", 372 | " \n", 373 | " \n", 374 | " \n", 375 | " \n", 376 | " \n", 377 | " \n", 378 | " \n", 379 | " \n", 380 | " \n", 381 | " \n", 382 | " \n", 383 | " \n", 384 | " \n", 385 | " \n", 386 | " \n", 387 | " \n", 388 | " \n", 389 | " \n", 390 | " \n", 391 | " \n", 392 | " \n", 393 | " \n", 394 | " \n", 395 | " \n", 396 | " \n", 397 | " \n", 398 | " \n", 399 | " \n", 400 | " \n", 401 | " \n", 402 | " \n", 403 | " \n", 404 | " \n", 405 | " \n", 406 | " \n", 407 | " \n", 408 | " \n", 409 | " \n", 410 | " \n", 411 | " \n", 412 | " \n", 413 | " \n", 414 | " \n", 415 | " \n", 416 | " \n", 417 | " \n", 418 | " \n", 419 | " \n", 420 | " \n", 421 | " \n", 422 | " \n", 423 | " \n", 424 | " \n", 425 | " \n", 426 | " \n", 427 | " \n", 428 | " \n", 429 | " \n", 430 | " \n", 431 | " \n", 432 | " \n", 433 | " \n", 434 | " \n", 435 | " \n", 436 | " \n", 437 | " \n", 438 | " \n", 439 | " \n", 440 | " \n", 441 | " \n", 442 | " \n", 443 | " \n", 444 | " \n", 445 | " \n", 446 | " \n", 447 | " \n", 448 | " \n", 449 | " \n", 450 | " \n", 451 | " \n", 452 | " \n", 453 | " \n", 454 | " \n", 455 | " \n", 456 | " \n", 457 | " \n", 458 | " \n", 459 | " \n", 460 | " \n", 461 | " \n", 462 | " \n", 463 | " \n", 464 | " \n", 465 | " \n", 466 | " \n", 467 | " \n", 468 | " \n", 469 | " \n", 470 | " \n", 471 | " \n", 472 | " \n", 473 | " \n", 474 | " \n", 475 | " \n", 476 | " \n", 477 | " \n", 478 | " \n", 479 | " \n", 480 | " \n", 481 | " \n", 482 | " \n", 483 | " \n", 484 | " \n", 485 | " \n", 486 | " \n", 487 | " \n", 488 | " \n", 489 | " \n", 490 | " \n", 491 | "
idcase_numberDATEblockiucrprimary_typedescriptionlocation_descriptionarrestdomesticbeatdistrictwardcommunity_area_numberfbicodex_coordinatey_coordinateYEARupdatedonlatitudelongitudelocation
3512276HK58771208/28/2004 05:50:56 PM047XX S KEDZIE AVE890THEFTFROM BUILDINGSMALL RETAIL STOREFALSEFALSE91191458611558381873050200402/10/2018 03:50:01 PM41.80744050-87.70395585(41.8074405, -87.703955849)
3406613HK45630606/26/2004 12:40:00 PM009XX N CENTRAL PARK AVE820THEFT$500 AND UNDEROTHERFALSEFALSE1112112723611522061906127200402/28/2018 03:56:25 PM41.89827996-87.71640551(41.898279962, -87.716405505)
8002131HT23359504/04/2011 05:45:00 AM043XX S WABASH AVE820THEFT$500 AND UNDERNURSING HOME/RETIREMENT HOMEFALSEFALSE2212338611774361876313201102/10/2018 03:50:01 PM41.81593313-87.62464213(41.815933131, -87.624642127)
7903289HT13352212/30/2010 04:30:00 PM083XX S KINGSTON AVE840THEFTFINANCIAL ID THEFT: OVER $300RESIDENCEFALSEFALSE4234746611946221850125201002/10/2018 03:50:01 PM41.74366532-87.56246276(41.743665322, -87.562462756)
10402076HZ13855102/02/2016 07:30:00 PM033XX W 66TH ST820THEFT$500 AND UNDERALLEYFALSEFALSE83181566611552401860661201602/10/2018 03:50:01 PM41.77345530-87.70648047(41.773455295, -87.706480471)
7732712HS54010609/29/2010 07:59:00 AM006XX W CHICAGO AVE810THEFTOVER $500PARKING LOT/GARAGE(NON.RESID.)FALSEFALSE1323122724611716681905607201002/10/2018 03:50:01 PM41.89644677-87.64493868(41.896446772, -87.644938678)
10769475HZ53477111/30/2016 01:15:00 AM050XX N KEDZIE AVE810THEFTOVER $500STREETFALSEFALSE1713173314611541331933314201602/10/2018 03:50:01 PM41.97284491-87.70860008(41.972844913, -87.708600079)
4494340HL79324312/16/2005 04:45:00 PM005XX E PERSHING RD860THEFTRETAIL THEFTGROCERY FOOD STORETRUEFALSE2132338611804481879234200502/28/2018 03:56:25 PM41.82387989-87.61350386(41.823879885, -87.613503857)
3778925HL14961001/28/2005 05:00:00 PM100XX S WASHTENAW AVE810THEFTOVER $500STREETFALSEFALSE2211221972611601291838040200502/28/2018 03:56:25 PM41.71128051-87.68917910(41.711280513, -87.689179097)
3324217HK36155105/13/2004 02:15:00 PM033XX W BELMONT AVE820THEFT$500 AND UNDERSMALL RETAIL STOREFALSEFALSE1733173521611535901921084200402/28/2018 03:56:25 PM41.93929582-87.71092344(41.939295821, -87.710923442)
" 492 | ], 493 | "text/plain": [ 494 | "[(3512276, 'HK587712', '08/28/2004 05:50:56 PM', '047XX S KEDZIE AVE', '890', 'THEFT', 'FROM BUILDING', 'SMALL RETAIL STORE', 'FALSE', 'FALSE', 911, 9, 14, 58, '6', 1155838, 1873050, 2004, '02/10/2018 03:50:01 PM', Decimal('41.80744050'), Decimal('-87.70395585'), '(41.8074405, -87.703955849)'),\n", 495 | " (3406613, 'HK456306', '06/26/2004 12:40:00 PM', '009XX N CENTRAL PARK AVE', '820', 'THEFT', '$500 AND UNDER', 'OTHER', 'FALSE', 'FALSE', 1112, 11, 27, 23, '6', 1152206, 1906127, 2004, '02/28/2018 03:56:25 PM', Decimal('41.89827996'), Decimal('-87.71640551'), '(41.898279962, -87.716405505)'),\n", 496 | " (8002131, 'HT233595', '04/04/2011 05:45:00 AM', '043XX S WABASH AVE', '820', 'THEFT', '$500 AND UNDER', 'NURSING HOME/RETIREMENT HOME', 'FALSE', 'FALSE', 221, 2, 3, 38, '6', 1177436, 1876313, 2011, '02/10/2018 03:50:01 PM', Decimal('41.81593313'), Decimal('-87.62464213'), '(41.815933131, -87.624642127)'),\n", 497 | " (7903289, 'HT133522', '12/30/2010 04:30:00 PM', '083XX S KINGSTON AVE', '840', 'THEFT', 'FINANCIAL ID THEFT: OVER $300', 'RESIDENCE', 'FALSE', 'FALSE', 423, 4, 7, 46, '6', 1194622, 1850125, 2010, '02/10/2018 03:50:01 PM', Decimal('41.74366532'), Decimal('-87.56246276'), '(41.743665322, -87.562462756)'),\n", 498 | " (10402076, 'HZ138551', '02/02/2016 07:30:00 PM', '033XX W 66TH ST', '820', 'THEFT', '$500 AND UNDER', 'ALLEY', 'FALSE', 'FALSE', 831, 8, 15, 66, '6', 1155240, 1860661, 2016, '02/10/2018 03:50:01 PM', Decimal('41.77345530'), Decimal('-87.70648047'), '(41.773455295, -87.706480471)'),\n", 499 | " (7732712, 'HS540106', '09/29/2010 07:59:00 AM', '006XX W CHICAGO AVE', '810', 'THEFT', 'OVER $500', 'PARKING LOT/GARAGE(NON.RESID.)', 'FALSE', 'FALSE', 1323, 12, 27, 24, '6', 1171668, 1905607, 2010, '02/10/2018 03:50:01 PM', Decimal('41.89644677'), Decimal('-87.64493868'), '(41.896446772, -87.644938678)'),\n", 500 | " (10769475, 'HZ534771', '11/30/2016 01:15:00 AM', '050XX N KEDZIE AVE', '810', 'THEFT', 'OVER $500', 'STREET', 'FALSE', 'FALSE', 1713, 17, 33, 14, '6', 1154133, 1933314, 2016, '02/10/2018 03:50:01 PM', Decimal('41.97284491'), Decimal('-87.70860008'), '(41.972844913, -87.708600079)'),\n", 501 | " (4494340, 'HL793243', '12/16/2005 04:45:00 PM', '005XX E PERSHING RD', '860', 'THEFT', 'RETAIL THEFT', 'GROCERY FOOD STORE', 'TRUE', 'FALSE', 213, 2, 3, 38, '6', 1180448, 1879234, 2005, '02/28/2018 03:56:25 PM', Decimal('41.82387989'), Decimal('-87.61350386'), '(41.823879885, -87.613503857)'),\n", 502 | " (3778925, 'HL149610', '01/28/2005 05:00:00 PM', '100XX S WASHTENAW AVE', '810', 'THEFT', 'OVER $500', 'STREET', 'FALSE', 'FALSE', 2211, 22, 19, 72, '6', 1160129, 1838040, 2005, '02/28/2018 03:56:25 PM', Decimal('41.71128051'), Decimal('-87.68917910'), '(41.711280513, -87.689179097)'),\n", 503 | " (3324217, 'HK361551', '05/13/2004 02:15:00 PM', '033XX W BELMONT AVE', '820', 'THEFT', '$500 AND UNDER', 'SMALL RETAIL STORE', 'FALSE', 'FALSE', 1733, 17, 35, 21, '6', 1153590, 1921084, 2004, '02/28/2018 03:56:25 PM', Decimal('41.93929582'), Decimal('-87.71092344'), '(41.939295821, -87.710923442)')]" 504 | ] 505 | }, 506 | "execution_count": 4, 507 | "metadata": {}, 508 | "output_type": "execute_result" 509 | } 510 | ], 511 | "source": [ 512 | "%sql select * from CHICAGO_CRIME_DATA limit 10" 513 | ] 514 | }, 515 | { 516 | "cell_type": "markdown", 517 | "metadata": {}, 518 | "source": [ 519 | "### Problem 3\n", 520 | "\n", 521 | "##### How many crimes involve an arrest?" 522 | ] 523 | }, 524 | { 525 | "cell_type": "code", 526 | "execution_count": 5, 527 | "metadata": {}, 528 | "outputs": [ 529 | { 530 | "name": "stdout", 531 | "output_type": "stream", 532 | "text": [ 533 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 534 | "Done.\n" 535 | ] 536 | }, 537 | { 538 | "data": { 539 | "text/html": [ 540 | "\n", 541 | " \n", 542 | " \n", 543 | " \n", 544 | " \n", 545 | " \n", 546 | " \n", 547 | "
1
163
" 548 | ], 549 | "text/plain": [ 550 | "[(Decimal('163'),)]" 551 | ] 552 | }, 553 | "execution_count": 5, 554 | "metadata": {}, 555 | "output_type": "execute_result" 556 | } 557 | ], 558 | "source": [ 559 | "%sql select count(*) from CHICAGO_CRIME_DATA \\\n", 560 | " where arrest = \"TRUE\"" 561 | ] 562 | }, 563 | { 564 | "cell_type": "markdown", 565 | "metadata": {}, 566 | "source": [ 567 | "### Problem 4\n", 568 | "\n", 569 | "##### Which unique types of crimes have been recorded at GAS STATION locations?\n" 570 | ] 571 | }, 572 | { 573 | "cell_type": "code", 574 | "execution_count": 6, 575 | "metadata": {}, 576 | "outputs": [ 577 | { 578 | "name": "stdout", 579 | "output_type": "stream", 580 | "text": [ 581 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 582 | "Done.\n" 583 | ] 584 | }, 585 | { 586 | "data": { 587 | "text/html": [ 588 | "\n", 589 | " \n", 590 | " \n", 591 | " \n", 592 | " \n", 593 | " \n", 594 | " \n", 595 | " \n", 596 | " \n", 597 | " \n", 598 | " \n", 599 | " \n", 600 | " \n", 601 | " \n", 602 | " \n", 603 | " \n", 604 | "
primary_type
CRIMINAL TRESPA
NARCOTICS
ROBBERY
THEFT
" 605 | ], 606 | "text/plain": [ 607 | "[('CRIMINAL TRESPA',), ('NARCOTICS',), ('ROBBERY',), ('THEFT',)]" 608 | ] 609 | }, 610 | "execution_count": 6, 611 | "metadata": {}, 612 | "output_type": "execute_result" 613 | } 614 | ], 615 | "source": [ 616 | "%sql select distinct(primary_type) from CHICAGO_CRIME_DATA \\\n", 617 | " where location_description = 'GAS STATION'" 618 | ] 619 | }, 620 | { 621 | "cell_type": "markdown", 622 | "metadata": {}, 623 | "source": [ 624 | "Hint: Which column lists types of crimes e.g. THEFT?" 625 | ] 626 | }, 627 | { 628 | "cell_type": "code", 629 | "execution_count": 7, 630 | "metadata": {}, 631 | "outputs": [ 632 | { 633 | "name": "stdout", 634 | "output_type": "stream", 635 | "text": [ 636 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 637 | "Done.\n" 638 | ] 639 | }, 640 | { 641 | "data": { 642 | "text/html": [ 643 | "\n", 644 | " \n", 645 | " \n", 646 | " \n", 647 | " \n", 648 | " \n", 649 | " \n", 650 | " \n", 651 | " \n", 652 | " \n", 653 | " \n", 654 | " \n", 655 | " \n", 656 | " \n", 657 | " \n", 658 | " \n", 659 | " \n", 660 | " \n", 661 | " \n", 662 | " \n", 663 | " \n", 664 | " \n", 665 | " \n", 666 | " \n", 667 | " \n", 668 | " \n", 669 | " \n", 670 | " \n", 671 | " \n", 672 | " \n", 673 | " \n", 674 | " \n", 675 | " \n", 676 | " \n", 677 | " \n", 678 | " \n", 679 | " \n", 680 | " \n", 681 | " \n", 682 | " \n", 683 | " \n", 684 | " \n", 685 | " \n", 686 | " \n", 687 | " \n", 688 | " \n", 689 | " \n", 690 | " \n", 691 | " \n", 692 | " \n", 693 | " \n", 694 | " \n", 695 | " \n", 696 | " \n", 697 | " \n", 698 | " \n", 699 | " \n", 700 | " \n", 701 | " \n", 702 | " \n", 703 | " \n", 704 | " \n", 705 | " \n", 706 | " \n", 707 | " \n", 708 | " \n", 709 | " \n", 710 | " \n", 711 | " \n", 712 | " \n", 713 | " \n", 714 | " \n", 715 | " \n", 716 | " \n", 717 | " \n", 718 | " \n", 719 | " \n", 720 | " \n", 721 | " \n", 722 | " \n", 723 | " \n", 724 | " \n", 725 | " \n", 726 | " \n", 727 | " \n", 728 | " \n", 729 | " \n", 730 | " \n", 731 | " \n", 732 | " \n", 733 | " \n", 734 | " \n", 735 | " \n", 736 | " \n", 737 | " \n", 738 | " \n", 739 | " \n", 740 | " \n", 741 | " \n", 742 | " \n", 743 | " \n", 744 | " \n", 745 | " \n", 746 | " \n", 747 | " \n", 748 | " \n", 749 | " \n", 750 | " \n", 751 | " \n", 752 | " \n", 753 | " \n", 754 | " \n", 755 | " \n", 756 | " \n", 757 | " \n", 758 | " \n", 759 | " \n", 760 | " \n", 761 | " \n", 762 | " \n", 763 | " \n", 764 | " \n", 765 | "
community_area_numbercommunity_area_namePERCENT OF HOUSING CROWDEDPERCENT HOUSEHOLDS BELOW POVERTYPERCENT AGED 16 UNEMPLOYEDPERCENT AGED 25 WITHOUT HIGH SCHOOL DIPLOMAPERCENT AGED UNDER 18 OR OVER 64PER_CAPITA_INCOME hardship_index
1Rogers Park7.723.68.718.227.52393939
2West Ridge7.817.28.820.838.52304046
3Uptown3.824.08.911.822.23578720
4Lincoln Square3.410.98.213.425.53752417
5North Center0.37.55.24.526.2571236
6Lake View1.111.44.72.617.0600585
7Lincoln Park0.812.35.13.621.5715512
8Near North Side1.912.97.02.522.6886691
9Edison Park1.13.36.57.435.3409598
10Norwood Park2.05.49.011.539.53287521
" 766 | ], 767 | "text/plain": [ 768 | "[(1, 'Rogers Park', Decimal('7.7'), Decimal('23.6'), Decimal('8.7'), Decimal('18.2'), Decimal('27.5'), 23939, 39),\n", 769 | " (2, 'West Ridge', Decimal('7.8'), Decimal('17.2'), Decimal('8.8'), Decimal('20.8'), Decimal('38.5'), 23040, 46),\n", 770 | " (3, 'Uptown', Decimal('3.8'), Decimal('24.0'), Decimal('8.9'), Decimal('11.8'), Decimal('22.2'), 35787, 20),\n", 771 | " (4, 'Lincoln Square', Decimal('3.4'), Decimal('10.9'), Decimal('8.2'), Decimal('13.4'), Decimal('25.5'), 37524, 17),\n", 772 | " (5, 'North Center', Decimal('0.3'), Decimal('7.5'), Decimal('5.2'), Decimal('4.5'), Decimal('26.2'), 57123, 6),\n", 773 | " (6, 'Lake View', Decimal('1.1'), Decimal('11.4'), Decimal('4.7'), Decimal('2.6'), Decimal('17.0'), 60058, 5),\n", 774 | " (7, 'Lincoln Park', Decimal('0.8'), Decimal('12.3'), Decimal('5.1'), Decimal('3.6'), Decimal('21.5'), 71551, 2),\n", 775 | " (8, 'Near North Side', Decimal('1.9'), Decimal('12.9'), Decimal('7.0'), Decimal('2.5'), Decimal('22.6'), 88669, 1),\n", 776 | " (9, 'Edison Park', Decimal('1.1'), Decimal('3.3'), Decimal('6.5'), Decimal('7.4'), Decimal('35.3'), 40959, 8),\n", 777 | " (10, 'Norwood Park', Decimal('2.0'), Decimal('5.4'), Decimal('9.0'), Decimal('11.5'), Decimal('39.5'), 32875, 21)]" 778 | ] 779 | }, 780 | "execution_count": 7, 781 | "metadata": {}, 782 | "output_type": "execute_result" 783 | } 784 | ], 785 | "source": [ 786 | "%sql select * from CENSUS_DATA limit 10 " 787 | ] 788 | }, 789 | { 790 | "cell_type": "code", 791 | "execution_count": 8, 792 | "metadata": {}, 793 | "outputs": [ 794 | { 795 | "name": "stdout", 796 | "output_type": "stream", 797 | "text": [ 798 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 799 | "Done.\n" 800 | ] 801 | }, 802 | { 803 | "data": { 804 | "text/html": [ 805 | "\n", 806 | " \n", 807 | " \n", 808 | " \n", 809 | " \n", 810 | " \n", 811 | " \n", 812 | " \n", 813 | " \n", 814 | " \n", 815 | " \n", 816 | " \n", 817 | " \n", 818 | " \n", 819 | " \n", 820 | " \n", 821 | " \n", 822 | " \n", 823 | " \n", 824 | " \n", 825 | " \n", 826 | " \n", 827 | " \n", 828 | " \n", 829 | " \n", 830 | " \n", 831 | " \n", 832 | " \n", 833 | " \n", 834 | " \n", 835 | " \n", 836 | " \n", 837 | " \n", 838 | " \n", 839 | " \n", 840 | " \n", 841 | " \n", 842 | " \n", 843 | " \n", 844 | " \n", 845 | " \n", 846 | " \n", 847 | " \n", 848 | " \n", 849 | " \n", 850 | " \n", 851 | " \n", 852 | " \n", 853 | " \n", 854 | " \n", 855 | " \n", 856 | " \n", 857 | " \n", 858 | " \n", 859 | " \n", 860 | " \n", 861 | " \n", 862 | " \n", 863 | " \n", 864 | " \n", 865 | " \n", 866 | " \n", 867 | " \n", 868 | " \n", 869 | " \n", 870 | " \n", 871 | " \n", 872 | " \n", 873 | " \n", 874 | " \n", 875 | " \n", 876 | " \n", 877 | " \n", 878 | " \n", 879 | " \n", 880 | " \n", 881 | " \n", 882 | " \n", 883 | " \n", 884 | " \n", 885 | " \n", 886 | " \n", 887 | " \n", 888 | " \n", 889 | " \n", 890 | " \n", 891 | " \n", 892 | " \n", 893 | " \n", 894 | " \n", 895 | " \n", 896 | " \n", 897 | " \n", 898 | " \n", 899 | " \n", 900 | " \n", 901 | " \n", 902 | " \n", 903 | " \n", 904 | " \n", 905 | " \n", 906 | " \n", 907 | " \n", 908 | " \n", 909 | " \n", 910 | " \n", 911 | " \n", 912 | " \n", 913 | " \n", 914 | " \n", 915 | " \n", 916 | " \n", 917 | " \n", 918 | " \n", 919 | " \n", 920 | " \n", 921 | " \n", 922 | " \n", 923 | " \n", 924 | " \n", 925 | " \n", 926 | " \n", 927 | " \n", 928 | " \n", 929 | " \n", 930 | " \n", 931 | " \n", 932 | " \n", 933 | " \n", 934 | " \n", 935 | " \n", 936 | " \n", 937 | " \n", 938 | " \n", 939 | " \n", 940 | " \n", 941 | " \n", 942 | " \n", 943 | " \n", 944 | " \n", 945 | " \n", 946 | " \n", 947 | " \n", 948 | " \n", 949 | " \n", 950 | " \n", 951 | " \n", 952 | " \n", 953 | " \n", 954 | " \n", 955 | " \n", 956 | " \n", 957 | " \n", 958 | " \n", 959 | " \n", 960 | " \n", 961 | " \n", 962 | " \n", 963 | " \n", 964 | " \n", 965 | " \n", 966 | " \n", 967 | " \n", 968 | " \n", 969 | " \n", 970 | " \n", 971 | " \n", 972 | " \n", 973 | " \n", 974 | " \n", 975 | " \n", 976 | " \n", 977 | " \n", 978 | " \n", 979 | " \n", 980 | " \n", 981 | " \n", 982 | " \n", 983 | " \n", 984 | " \n", 985 | " \n", 986 | " \n", 987 | " \n", 988 | " \n", 989 | " \n", 990 | " \n", 991 | " \n", 992 | " \n", 993 | " \n", 994 | " \n", 995 | " \n", 996 | " \n", 997 | " \n", 998 | " \n", 999 | " \n", 1000 | " \n", 1001 | " \n", 1002 | " \n", 1003 | " \n", 1004 | " \n", 1005 | " \n", 1006 | " \n", 1007 | " \n", 1008 | " \n", 1009 | " \n", 1010 | " \n", 1011 | " \n", 1012 | " \n", 1013 | " \n", 1014 | " \n", 1015 | " \n", 1016 | " \n", 1017 | " \n", 1018 | " \n", 1019 | " \n", 1020 | " \n", 1021 | " \n", 1022 | " \n", 1023 | " \n", 1024 | " \n", 1025 | " \n", 1026 | " \n", 1027 | " \n", 1028 | " \n", 1029 | " \n", 1030 | " \n", 1031 | " \n", 1032 | " \n", 1033 | " \n", 1034 | " \n", 1035 | " \n", 1036 | " \n", 1037 | " \n", 1038 | " \n", 1039 | " \n", 1040 | " \n", 1041 | " \n", 1042 | " \n", 1043 | " \n", 1044 | " \n", 1045 | " \n", 1046 | " \n", 1047 | " \n", 1048 | " \n", 1049 | " \n", 1050 | " \n", 1051 | " \n", 1052 | " \n", 1053 | " \n", 1054 | " \n", 1055 | " \n", 1056 | " \n", 1057 | " \n", 1058 | " \n", 1059 | " \n", 1060 | " \n", 1061 | " \n", 1062 | " \n", 1063 | " \n", 1064 | " \n", 1065 | " \n", 1066 | " \n", 1067 | " \n", 1068 | " \n", 1069 | " \n", 1070 | " \n", 1071 | " \n", 1072 | " \n", 1073 | " \n", 1074 | " \n", 1075 | " \n", 1076 | " \n", 1077 | " \n", 1078 | " \n", 1079 | " \n", 1080 | " \n", 1081 | " \n", 1082 | " \n", 1083 | " \n", 1084 | " \n", 1085 | " \n", 1086 | " \n", 1087 | " \n", 1088 | " \n", 1089 | " \n", 1090 | " \n", 1091 | " \n", 1092 | " \n", 1093 | " \n", 1094 | " \n", 1095 | " \n", 1096 | " \n", 1097 | " \n", 1098 | " \n", 1099 | " \n", 1100 | " \n", 1101 | " \n", 1102 | " \n", 1103 | " \n", 1104 | " \n", 1105 | " \n", 1106 | " \n", 1107 | " \n", 1108 | " \n", 1109 | " \n", 1110 | " \n", 1111 | " \n", 1112 | " \n", 1113 | " \n", 1114 | " \n", 1115 | " \n", 1116 | " \n", 1117 | " \n", 1118 | " \n", 1119 | " \n", 1120 | " \n", 1121 | " \n", 1122 | " \n", 1123 | " \n", 1124 | " \n", 1125 | " \n", 1126 | " \n", 1127 | " \n", 1128 | " \n", 1129 | " \n", 1130 | " \n", 1131 | " \n", 1132 | " \n", 1133 | " \n", 1134 | " \n", 1135 | " \n", 1136 | " \n", 1137 | " \n", 1138 | " \n", 1139 | " \n", 1140 | " \n", 1141 | " \n", 1142 | " \n", 1143 | " \n", 1144 | " \n", 1145 | " \n", 1146 | " \n", 1147 | " \n", 1148 | " \n", 1149 | " \n", 1150 | " \n", 1151 | " \n", 1152 | " \n", 1153 | " \n", 1154 | " \n", 1155 | " \n", 1156 | " \n", 1157 | " \n", 1158 | " \n", 1159 | " \n", 1160 | " \n", 1161 | " \n", 1162 | " \n", 1163 | " \n", 1164 | " \n", 1165 | " \n", 1166 | " \n", 1167 | " \n", 1168 | " \n", 1169 | " \n", 1170 | " \n", 1171 | " \n", 1172 | " \n", 1173 | " \n", 1174 | " \n", 1175 | " \n", 1176 | " \n", 1177 | " \n", 1178 | " \n", 1179 | " \n", 1180 | " \n", 1181 | " \n", 1182 | " \n", 1183 | " \n", 1184 | " \n", 1185 | " \n", 1186 | " \n", 1187 | " \n", 1188 | " \n", 1189 | " \n", 1190 | " \n", 1191 | " \n", 1192 | " \n", 1193 | " \n", 1194 | " \n", 1195 | " \n", 1196 | " \n", 1197 | " \n", 1198 | " \n", 1199 | " \n", 1200 | " \n", 1201 | " \n", 1202 | " \n", 1203 | " \n", 1204 | " \n", 1205 | " \n", 1206 | " \n", 1207 | " \n", 1208 | " \n", 1209 | " \n", 1210 | " \n", 1211 | " \n", 1212 | " \n", 1213 | " \n", 1214 | " \n", 1215 | " \n", 1216 | " \n", 1217 | " \n", 1218 | " \n", 1219 | " \n", 1220 | " \n", 1221 | " \n", 1222 | " \n", 1223 | " \n", 1224 | " \n", 1225 | " \n", 1226 | " \n", 1227 | " \n", 1228 | " \n", 1229 | " \n", 1230 | " \n", 1231 | " \n", 1232 | " \n", 1233 | " \n", 1234 | " \n", 1235 | " \n", 1236 | " \n", 1237 | " \n", 1238 | " \n", 1239 | " \n", 1240 | " \n", 1241 | " \n", 1242 | " \n", 1243 | " \n", 1244 | " \n", 1245 | " \n", 1246 | " \n", 1247 | " \n", 1248 | " \n", 1249 | " \n", 1250 | " \n", 1251 | " \n", 1252 | " \n", 1253 | " \n", 1254 | " \n", 1255 | " \n", 1256 | " \n", 1257 | " \n", 1258 | " \n", 1259 | " \n", 1260 | " \n", 1261 | " \n", 1262 | " \n", 1263 | " \n", 1264 | " \n", 1265 | " \n", 1266 | " \n", 1267 | " \n", 1268 | " \n", 1269 | " \n", 1270 | " \n", 1271 | " \n", 1272 | " \n", 1273 | " \n", 1274 | " \n", 1275 | " \n", 1276 | " \n", 1277 | " \n", 1278 | " \n", 1279 | " \n", 1280 | " \n", 1281 | " \n", 1282 | " \n", 1283 | " \n", 1284 | " \n", 1285 | " \n", 1286 | "
school_idname_of_schoolElementary, Middle, or High Schoolstreet_addresscitystatezip_codephone_numberlinknetwork_managercollaborative_nameadequate_yearly_progress_made_track_schedulecps_performance_policy_statuscps_performance_policy_levelhealthy_school_certifiedsafety_iconsafety_scorefamily_involvement_iconfamily_involvement_scoreenvironment_iconenvironment_scoreinstruction_iconinstruction_scoreleaders_iconleaders_scoreteachers_iconteachers_scoreparent_engagement_iconparent_engagement_scoreparent_environment_iconparent_environment_scoreaverage_student_attendancerate_of_misconducts__per_100_students_average_teacher_attendanceindividualized_education_program_compliance_ratepk_2_literacy__pk_2_math__gr3_5_grade_level_math__gr3_5_grade_level_read__gr3_5_keep_pace_read__gr3_5_keep_pace_math__gr6_8_grade_level_math__gr6_8_grade_level_read__gr6_8_keep_pace_math_gr6_8_keep_pace_read__gr_8_explore_math__gr_8_explore_read__isat_exceeding_math__isat_exceeding_reading__isat_value_add_mathisat_value_add_readisat_value_add_color_mathisat_value_add_color_readstudents_taking__algebra__students_passing__algebra__9th Grade EXPLORE (2009)9th Grade EXPLORE (2010)10th Grade PLAN (2009)10th Grade PLAN (2010)net_change_explore_and_plan11th Grade Average ACT (2011)net_change_plan_and_actcollege_eligibility__graduation_rate__college_enrollment_rate__college_enrollmentgeneral_services_routefreshman_on_track_rate__x_coordinatey_coordinatelatitudelongitudecommunity_area_numbercommunity_area_namewardpolice_districtlocation
610038Abraham Lincoln Elementary SchoolES615 W Kemper PlChicagoIL60614(773) 534-5720http://schoolreports.cps.edu/SchoolProgressReport_Eng/Spring2011Eng_610038.pdfFullerton Elementary NetworkNORTH-NORTHWEST SIDE COLLABORATIVENoStandardNot on ProbationLevel 1YesVery Strong99Very Strong99Strong74Strong66Strong65Strong70Strong56Average4796.00%2.096.40%95.80%80.143.389.684.960.762.681.985.25262.466.377.969.764.40.20.9YellowGreen67.154.5NDANDANDANDANDANDANDANDANDANDA81333NDA1171699.4581915829.42841.92449696-87.644521637LINCOLN PARK4318(41.92449696, -87.64452163)
610281Adam Clayton Powell Paideia Community Academy Elementary SchoolES7511 S South Shore DrChicagoIL60649(773) 535-6650http://schoolreports.cps.edu/SchoolProgressReport_Eng/Spring2011Eng_610281.pdfSkyway Elementary NetworkSOUTH SIDE COLLABORATIVENoTrack_ENot on ProbationLevel 1NoAverage54Strong66Strong74Very Strong84Strong63Strong76Weak46Average5095.60%15.795.30%100.00%62.451.721.915.12942.838.527.444.842.714.134.416.816.50.71.4GreenGreen17.227.3NDANDANDANDANDANDANDANDANDANDA52146NDA1196129.9851856209.46641.76032435-87.5567362743SOUTH SHORE74(41.76032435, -87.55673627)
610185Adlai E Stevenson Elementary SchoolES8010 S Kostner AveChicagoIL60652(773) 535-2280http://schoolreports.cps.edu/SchoolProgressReport_Eng/Spring2011Eng_610185.pdfMidway Elementary NetworkSOUTHWEST SIDE COLLABORATIVENoStandardNot on ProbationLevel 2NoStrong61NDANDAAverage50Weak36NDANDANDANDAAverage47Weak4195.70%2.394.70%98.30%53.726.638.334.743.757.348.839.246.8447.521.918.315.5-0.9-1.0RedRedNDANDANDANDANDANDANDANDANDANDANDANDA132444NDA1148427.1651851012.21541.74711093-87.7317024870ASHBURN138(41.74711093, -87.73170248)
609993Agustin Lara Elementary AcademyES4619 S Wolcott AveChicagoIL60609(773) 535-4389http://schoolreports.cps.edu/SchoolProgressReport_Eng/Spring2011Eng_609993.pdfPershing Elementary NetworkSOUTHWEST SIDE COLLABORATIVENoTrack_ENot on ProbationLevel 1NoAverage56Average44Average45Weak37Strong65Average48Average53Strong5895.50%10.495.80%100.00%76.9NDA2624.761.849.739.227.269.760.69.118.211.19.60.92.4GreenGreen42.925NDANDANDANDANDANDANDANDANDANDA55642NDA1164504.2901873959.19941.80975690-87.6721446061NEW CITY209(41.8097569, -87.6721446)
610513Air Force Academy High SchoolHS3630 S Wells StChicagoIL60609(773) 535-1590http://schoolreports.cps.edu/SchoolProgressReport_Eng/Spring2011Eng_610513.pdfSouthwest Side High School NetworkSOUTHWEST SIDE COLLABORATIVENDAStandardNot on ProbationNot Enough DataYesAverage49Strong60Strong60Average55Average45Average54Average53Average4993.30%15.696.90%100.00%NDANDANDANDANDANDANDANDANDANDANDANDANoneNoneNoneNoneNDANDANDANDA14.614.8NDA161.4NDANDANDANDANDA3024091.81175177.6221880745.12641.82814609-87.6327936934ARMOUR SQUARE119(41.82814609, -87.63279369)
" 1287 | ], 1288 | "text/plain": [ 1289 | "[(610038, 'Abraham Lincoln Elementary School', 'ES', '615 W Kemper Pl', 'Chicago', 'IL', 60614, '(773) 534-5720', 'http://schoolreports.cps.edu/SchoolProgressReport_Eng/Spring2011Eng_610038.pdf', 'Fullerton Elementary Network', 'NORTH-NORTHWEST SIDE COLLABORATIVE', 'No', 'Standard', 'Not on Probation', 'Level 1', 'Yes', 'Very Strong', 99, 'Very Strong', '99', 'Strong', 74, 'Strong', 66, 'Strong', '65', 'Strong', '70', 'Strong', '56', 'Average', '47', '96.00%', Decimal('2.0'), '96.40%', '95.80%', '80.1', '43.3', '89.6', '84.9', '60.7', '62.6', '81.9', '85.2', '52', '62.4', '66.3', '77.9', Decimal('69.7'), Decimal('64.4'), Decimal('0.2'), Decimal('0.9'), 'Yellow', 'Green', '67.1', '54.5', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 813, 33, 'NDA', Decimal('1171699.458'), Decimal('1915829.428'), Decimal('41.92449696'), Decimal('-87.64452163'), 7, 'LINCOLN PARK', 43, 18, '(41.92449696, -87.64452163)'),\n", 1290 | " (610281, 'Adam Clayton Powell Paideia Community Academy Elementary School', 'ES', '7511 S South Shore Dr', 'Chicago', 'IL', 60649, '(773) 535-6650', 'http://schoolreports.cps.edu/SchoolProgressReport_Eng/Spring2011Eng_610281.pdf', 'Skyway Elementary Network', 'SOUTH SIDE COLLABORATIVE', 'No', 'Track_E', 'Not on Probation', 'Level 1', 'No', 'Average', 54, 'Strong', '66', 'Strong', 74, 'Very Strong', 84, 'Strong', '63', 'Strong', '76', 'Weak', '46', 'Average', '50', '95.60%', Decimal('15.7'), '95.30%', '100.00%', '62.4', '51.7', '21.9', '15.1', '29', '42.8', '38.5', '27.4', '44.8', '42.7', '14.1', '34.4', Decimal('16.8'), Decimal('16.5'), Decimal('0.7'), Decimal('1.4'), 'Green', 'Green', '17.2', '27.3', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 521, 46, 'NDA', Decimal('1196129.985'), Decimal('1856209.466'), Decimal('41.76032435'), Decimal('-87.55673627'), 43, 'SOUTH SHORE', 7, 4, '(41.76032435, -87.55673627)'),\n", 1291 | " (610185, 'Adlai E Stevenson Elementary School', 'ES', '8010 S Kostner Ave', 'Chicago', 'IL', 60652, '(773) 535-2280', 'http://schoolreports.cps.edu/SchoolProgressReport_Eng/Spring2011Eng_610185.pdf', 'Midway Elementary Network', 'SOUTHWEST SIDE COLLABORATIVE', 'No', 'Standard', 'Not on Probation', 'Level 2', 'No', 'Strong', 61, 'NDA', 'NDA', 'Average', 50, 'Weak', 36, 'NDA', 'NDA', 'NDA', 'NDA', 'Average', '47', 'Weak', '41', '95.70%', Decimal('2.3'), '94.70%', '98.30%', '53.7', '26.6', '38.3', '34.7', '43.7', '57.3', '48.8', '39.2', '46.8', '44', '7.5', '21.9', Decimal('18.3'), Decimal('15.5'), Decimal('-0.9'), Decimal('-1.0'), 'Red', 'Red', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 1324, 44, 'NDA', Decimal('1148427.165'), Decimal('1851012.215'), Decimal('41.74711093'), Decimal('-87.73170248'), 70, 'ASHBURN', 13, 8, '(41.74711093, -87.73170248)'),\n", 1292 | " (609993, 'Agustin Lara Elementary Academy', 'ES', '4619 S Wolcott Ave', 'Chicago', 'IL', 60609, '(773) 535-4389', 'http://schoolreports.cps.edu/SchoolProgressReport_Eng/Spring2011Eng_609993.pdf', 'Pershing Elementary Network', 'SOUTHWEST SIDE COLLABORATIVE', 'No', 'Track_E', 'Not on Probation', 'Level 1', 'No', 'Average', 56, 'Average', '44', 'Average', 45, 'Weak', 37, 'Strong', '65', 'Average', '48', 'Average', '53', 'Strong', '58', '95.50%', Decimal('10.4'), '95.80%', '100.00%', '76.9', 'NDA', '26', '24.7', '61.8', '49.7', '39.2', '27.2', '69.7', '60.6', '9.1', '18.2', Decimal('11.1'), Decimal('9.6'), Decimal('0.9'), Decimal('2.4'), 'Green', 'Green', '42.9', '25', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 556, 42, 'NDA', Decimal('1164504.290'), Decimal('1873959.199'), Decimal('41.80975690'), Decimal('-87.67214460'), 61, 'NEW CITY', 20, 9, '(41.8097569, -87.6721446)'),\n", 1293 | " (610513, 'Air Force Academy High School', 'HS', '3630 S Wells St', 'Chicago', 'IL', 60609, '(773) 535-1590', 'http://schoolreports.cps.edu/SchoolProgressReport_Eng/Spring2011Eng_610513.pdf', 'Southwest Side High School Network', 'SOUTHWEST SIDE COLLABORATIVE', 'NDA', 'Standard', 'Not on Probation', 'Not Enough Data', 'Yes', 'Average', 49, 'Strong', '60', 'Strong', 60, 'Average', 55, 'Average', '45', 'Average', '54', 'Average', '53', 'Average', '49', '93.30%', Decimal('15.6'), '96.90%', '100.00%', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', None, None, None, None, 'NDA', 'NDA', 'NDA', 'NDA', '14.6', '14.8', 'NDA', '16', '1.4', 'NDA', 'NDA', 'NDA', 'NDA', 'NDA', 302, 40, '91.8', Decimal('1175177.622'), Decimal('1880745.126'), Decimal('41.82814609'), Decimal('-87.63279369'), 34, 'ARMOUR SQUARE', 11, 9, '(41.82814609, -87.63279369)')]" 1294 | ] 1295 | }, 1296 | "execution_count": 8, 1297 | "metadata": {}, 1298 | "output_type": "execute_result" 1299 | } 1300 | ], 1301 | "source": [ 1302 | "%sql select * from CHICAGO_PUBLIC_SCHOOLS limit 5" 1303 | ] 1304 | }, 1305 | { 1306 | "cell_type": "markdown", 1307 | "metadata": {}, 1308 | "source": [ 1309 | "### Problem 5\n", 1310 | "\n", 1311 | "##### In the CENUS_DATA table list all Community Areas whose names start with the letter ‘B’." 1312 | ] 1313 | }, 1314 | { 1315 | "cell_type": "code", 1316 | "execution_count": 9, 1317 | "metadata": {}, 1318 | "outputs": [ 1319 | { 1320 | "name": "stdout", 1321 | "output_type": "stream", 1322 | "text": [ 1323 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 1324 | "Done.\n" 1325 | ] 1326 | }, 1327 | { 1328 | "data": { 1329 | "text/html": [ 1330 | "\n", 1331 | " \n", 1332 | " \n", 1333 | " \n", 1334 | " \n", 1335 | " \n", 1336 | " \n", 1337 | " \n", 1338 | " \n", 1339 | " \n", 1340 | " \n", 1341 | " \n", 1342 | " \n", 1343 | " \n", 1344 | " \n", 1345 | " \n", 1346 | " \n", 1347 | " \n", 1348 | " \n", 1349 | "
community_area_name
Belmont Cragin
Burnside
Brighton Park
Bridgeport
Beverly
" 1350 | ], 1351 | "text/plain": [ 1352 | "[('Belmont Cragin',),\n", 1353 | " ('Burnside',),\n", 1354 | " ('Brighton Park',),\n", 1355 | " ('Bridgeport',),\n", 1356 | " ('Beverly',)]" 1357 | ] 1358 | }, 1359 | "execution_count": 9, 1360 | "metadata": {}, 1361 | "output_type": "execute_result" 1362 | } 1363 | ], 1364 | "source": [ 1365 | "%sql select community_area_name from CENSUS_DATA \\\n", 1366 | " where community_area_name like 'B%'" 1367 | ] 1368 | }, 1369 | { 1370 | "cell_type": "markdown", 1371 | "metadata": {}, 1372 | "source": [ 1373 | "### Problem 6\n", 1374 | "\n", 1375 | "##### Which schools in Community Areas 10 to 15 are healthy school certified?" 1376 | ] 1377 | }, 1378 | { 1379 | "cell_type": "code", 1380 | "execution_count": 10, 1381 | "metadata": {}, 1382 | "outputs": [ 1383 | { 1384 | "name": "stdout", 1385 | "output_type": "stream", 1386 | "text": [ 1387 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 1388 | "Done.\n" 1389 | ] 1390 | }, 1391 | { 1392 | "data": { 1393 | "text/html": [ 1394 | "\n", 1395 | " \n", 1396 | " \n", 1397 | " \n", 1398 | " \n", 1399 | " \n", 1400 | " \n", 1401 | "
name_of_school
Rufus M Hitch Elementary School
" 1402 | ], 1403 | "text/plain": [ 1404 | "[('Rufus M Hitch Elementary School',)]" 1405 | ] 1406 | }, 1407 | "execution_count": 10, 1408 | "metadata": {}, 1409 | "output_type": "execute_result" 1410 | } 1411 | ], 1412 | "source": [ 1413 | "%sql select name_of_school from CHICAGO_PUBLIC_SCHOOLS \\\n", 1414 | " where healthy_school_certified = 'Yes' \\\n", 1415 | " and community_area_number between 10 and 15" 1416 | ] 1417 | }, 1418 | { 1419 | "cell_type": "markdown", 1420 | "metadata": {}, 1421 | "source": [ 1422 | "### Problem 7\n", 1423 | "\n", 1424 | "##### What is the average school Safety Score? " 1425 | ] 1426 | }, 1427 | { 1428 | "cell_type": "code", 1429 | "execution_count": 11, 1430 | "metadata": {}, 1431 | "outputs": [ 1432 | { 1433 | "name": "stdout", 1434 | "output_type": "stream", 1435 | "text": [ 1436 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 1437 | "Done.\n" 1438 | ] 1439 | }, 1440 | { 1441 | "data": { 1442 | "text/html": [ 1443 | "\n", 1444 | " \n", 1445 | " \n", 1446 | " \n", 1447 | " \n", 1448 | " \n", 1449 | " \n", 1450 | "
mean_safety_score
49.504873
" 1451 | ], 1452 | "text/plain": [ 1453 | "[(Decimal('49.504873'),)]" 1454 | ] 1455 | }, 1456 | "execution_count": 11, 1457 | "metadata": {}, 1458 | "output_type": "execute_result" 1459 | } 1460 | ], 1461 | "source": [ 1462 | "%sql select avg(safety_score) as Mean_Safety_Score from CHICAGO_PUBLIC_SCHOOLS" 1463 | ] 1464 | }, 1465 | { 1466 | "cell_type": "markdown", 1467 | "metadata": {}, 1468 | "source": [ 1469 | "### Problem 8\n", 1470 | "\n", 1471 | "##### List the top 5 Community Areas by average College Enrollment [number of students] " 1472 | ] 1473 | }, 1474 | { 1475 | "cell_type": "code", 1476 | "execution_count": 20, 1477 | "metadata": {}, 1478 | "outputs": [ 1479 | { 1480 | "name": "stdout", 1481 | "output_type": "stream", 1482 | "text": [ 1483 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 1484 | "Done.\n" 1485 | ] 1486 | }, 1487 | { 1488 | "data": { 1489 | "text/html": [ 1490 | "\n", 1491 | " \n", 1492 | " \n", 1493 | " \n", 1494 | " \n", 1495 | " \n", 1496 | " \n", 1497 | " \n", 1498 | " \n", 1499 | " \n", 1500 | " \n", 1501 | " \n", 1502 | " \n", 1503 | " \n", 1504 | " \n", 1505 | " \n", 1506 | " \n", 1507 | " \n", 1508 | " \n", 1509 | " \n", 1510 | " \n", 1511 | " \n", 1512 | " \n", 1513 | " \n", 1514 | " \n", 1515 | "
community_area_nameavg_college_enrollment
ARCHER HEIGHTS2411.50
MONTCLARE1317.00
WEST ELSDON1233.33
BRIGHTON PARK1205.88
BELMONT CRAGIN1198.83
" 1516 | ], 1517 | "text/plain": [ 1518 | "[('ARCHER HEIGHTS', Decimal('2411.50')),\n", 1519 | " ('MONTCLARE', Decimal('1317.00')),\n", 1520 | " ('WEST ELSDON', Decimal('1233.33')),\n", 1521 | " ('BRIGHTON PARK', Decimal('1205.88')),\n", 1522 | " ('BELMONT CRAGIN', Decimal('1198.83'))]" 1523 | ] 1524 | }, 1525 | "execution_count": 20, 1526 | "metadata": {}, 1527 | "output_type": "execute_result" 1528 | } 1529 | ], 1530 | "source": [ 1531 | "%sql select community_area_name, cast(round(AVG(college_enrollment),2) as decimal(10,2)) as avg_college_enrollment \\\n", 1532 | "from CHICAGO_PUBLIC_SCHOOLS \\\n", 1533 | " group by community_area_name \\\n", 1534 | " order by avg_college_enrollment desc limit 5" 1535 | ] 1536 | }, 1537 | { 1538 | "cell_type": "markdown", 1539 | "metadata": {}, 1540 | "source": [ 1541 | "### Problem 9\n", 1542 | "\n", 1543 | "##### Use a sub-query to determine which Community Area has the least value for school Safety Score? " 1544 | ] 1545 | }, 1546 | { 1547 | "cell_type": "code", 1548 | "execution_count": 13, 1549 | "metadata": {}, 1550 | "outputs": [ 1551 | { 1552 | "name": "stdout", 1553 | "output_type": "stream", 1554 | "text": [ 1555 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 1556 | "Done.\n" 1557 | ] 1558 | }, 1559 | { 1560 | "data": { 1561 | "text/html": [ 1562 | "\n", 1563 | " \n", 1564 | " \n", 1565 | " \n", 1566 | " \n", 1567 | " \n", 1568 | " \n", 1569 | " \n", 1570 | " \n", 1571 | "
community_area_namesafety_score
WASHINGTON PARK1
" 1572 | ], 1573 | "text/plain": [ 1574 | "[('WASHINGTON PARK', 1)]" 1575 | ] 1576 | }, 1577 | "execution_count": 13, 1578 | "metadata": {}, 1579 | "output_type": "execute_result" 1580 | } 1581 | ], 1582 | "source": [ 1583 | "%sql select community_area_name, safety_score from CHICAGO_PUBLIC_SCHOOLS \\\n", 1584 | " where safety_score = (select min(safety_score) from CHICAGO_PUBLIC_SCHOOLS)" 1585 | ] 1586 | }, 1587 | { 1588 | "cell_type": "markdown", 1589 | "metadata": {}, 1590 | "source": [ 1591 | "### Problem 10\n", 1592 | "\n", 1593 | "##### [Without using an explicit JOIN operator] Find the Per Capita Income of the Community Area which has a school Safety Score of 1." 1594 | ] 1595 | }, 1596 | { 1597 | "cell_type": "code", 1598 | "execution_count": 14, 1599 | "metadata": {}, 1600 | "outputs": [ 1601 | { 1602 | "name": "stdout", 1603 | "output_type": "stream", 1604 | "text": [ 1605 | " * ibm_db_sa://tnx67692:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", 1606 | "Done.\n" 1607 | ] 1608 | }, 1609 | { 1610 | "data": { 1611 | "text/html": [ 1612 | "\n", 1613 | " \n", 1614 | " \n", 1615 | " \n", 1616 | " \n", 1617 | " \n", 1618 | " \n", 1619 | " \n", 1620 | " \n", 1621 | "
community_area_namePER_CAPITA_INCOME
Washington Park13785
" 1622 | ], 1623 | "text/plain": [ 1624 | "[('Washington Park', 13785)]" 1625 | ] 1626 | }, 1627 | "execution_count": 14, 1628 | "metadata": {}, 1629 | "output_type": "execute_result" 1630 | } 1631 | ], 1632 | "source": [ 1633 | "%sql select community_area_name, \"PER_CAPITA_INCOME \" from CENSUS_DATA \\\n", 1634 | " where community_area_number = (select community_area_number from CHICAGO_PUBLIC_SCHOOLS where safety_score = 1)" 1635 | ] 1636 | }, 1637 | { 1638 | "cell_type": "markdown", 1639 | "metadata": {}, 1640 | "source": [ 1641 | "Copyright © 2018 [cognitiveclass.ai](cognitiveclass.ai?utm_source=bducopyrightlink&utm_medium=dswb&utm_campaign=bdu). This notebook and its source code are released under the terms of the [MIT License](https://bigdatauniversity.com/mit-license/).\n" 1642 | ] 1643 | } 1644 | ], 1645 | "metadata": { 1646 | "kernelspec": { 1647 | "display_name": "Python", 1648 | "language": "python", 1649 | "name": "conda-env-python-py" 1650 | }, 1651 | "language_info": { 1652 | "codemirror_mode": { 1653 | "name": "ipython", 1654 | "version": 3 1655 | }, 1656 | "file_extension": ".py", 1657 | "mimetype": "text/x-python", 1658 | "name": "python", 1659 | "nbconvert_exporter": "python", 1660 | "pygments_lexer": "ipython3", 1661 | "version": "3.6.7" 1662 | }, 1663 | "widgets": { 1664 | "state": {}, 1665 | "version": "1.1.2" 1666 | } 1667 | }, 1668 | "nbformat": 4, 1669 | "nbformat_minor": 4 1670 | } 1671 | --------------------------------------------------------------------------------