|
158 | 158 | "metadata": {},
|
159 | 159 | "outputs": [],
|
160 | 160 | "source": [
|
161 |
| - "numbers = [12, 20, 43, 88, 97, 100, 105, 110]\n", |
| 161 | + "numbers = [12, 20.2, 43, 88.88, 97, 100, 105, 110.9167]\n", |
162 | 162 | "\n",
|
163 | 163 | "for number in numbers:\n",
|
164 | 164 | " if number > 100:\n",
|
|
185 | 185 | " \n",
|
186 | 186 | "The result of this is a single list, number, or string with a summary value for the entire collection being looped over.\n",
|
187 | 187 | "\n",
|
188 |
| - "Returning to the tire pressure example, we can make a new list with all of the tire pressures rounded:" |
| 188 | + "We can make a new list with all of the rounded numbers:" |
189 | 189 | ]
|
190 | 190 | },
|
191 | 191 | {
|
|
298 | 298 | },
|
299 | 299 | {
|
300 | 300 | "cell_type": "code",
|
301 |
| - "execution_count": 2, |
302 |
| - "metadata": {}, |
303 |
| - "outputs": [ |
304 |
| - { |
305 |
| - "data": { |
306 |
| - "text/html": [ |
307 |
| - "<div><div id=882af88a-033f-431f-a12e-16e795baa656 style=\"display:none; background-color:#9D6CFF; color:white; width:200px; height:30px; padding-left:5px; border-radius:4px; flex-direction:row; justify-content:space-around; align-items:center;\" onmouseover=\"this.style.backgroundColor='#BA9BF8'\" onmouseout=\"this.style.backgroundColor='#9D6CFF'\" onclick=\"window.commands?.execute('create-mitosheet-from-dataframe-output');\">See Full Dataframe in Mito</div> <script> if (window.commands?.hasCommand('create-mitosheet-from-dataframe-output')) document.getElementById('882af88a-033f-431f-a12e-16e795baa656').style.display = 'flex' </script> <table border=\"1\" class=\"dataframe\">\n", |
308 |
| - " <thead>\n", |
309 |
| - " <tr style=\"text-align: right;\">\n", |
310 |
| - " <th></th>\n", |
311 |
| - " <th>country</th>\n", |
312 |
| - " <th>year</th>\n", |
313 |
| - " <th>pop</th>\n", |
314 |
| - " <th>continent</th>\n", |
315 |
| - " <th>lifeExp</th>\n", |
316 |
| - " <th>gdpPercap</th>\n", |
317 |
| - " <th>gniPercap</th>\n", |
318 |
| - " </tr>\n", |
319 |
| - " </thead>\n", |
320 |
| - " <tbody>\n", |
321 |
| - " <tr>\n", |
322 |
| - " <th>0</th>\n", |
323 |
| - " <td>Afghanistan</td>\n", |
324 |
| - " <td>1962</td>\n", |
325 |
| - " <td>10267083.0</td>\n", |
326 |
| - " <td>Asia</td>\n", |
327 |
| - " <td>31.997</td>\n", |
328 |
| - " <td>853.100710</td>\n", |
329 |
| - " <td>NaN</td>\n", |
330 |
| - " </tr>\n", |
331 |
| - " <tr>\n", |
332 |
| - " <th>1</th>\n", |
333 |
| - " <td>Afghanistan</td>\n", |
334 |
| - " <td>1967</td>\n", |
335 |
| - " <td>11537966.0</td>\n", |
336 |
| - " <td>Asia</td>\n", |
337 |
| - " <td>34.020</td>\n", |
338 |
| - " <td>836.197138</td>\n", |
339 |
| - " <td>NaN</td>\n", |
340 |
| - " </tr>\n", |
341 |
| - " <tr>\n", |
342 |
| - " <th>2</th>\n", |
343 |
| - " <td>Afghanistan</td>\n", |
344 |
| - " <td>1972</td>\n", |
345 |
| - " <td>13079460.0</td>\n", |
346 |
| - " <td>Asia</td>\n", |
347 |
| - " <td>36.088</td>\n", |
348 |
| - " <td>739.981106</td>\n", |
349 |
| - " <td>NaN</td>\n", |
350 |
| - " </tr>\n", |
351 |
| - " <tr>\n", |
352 |
| - " <th>3</th>\n", |
353 |
| - " <td>Afghanistan</td>\n", |
354 |
| - " <td>1977</td>\n", |
355 |
| - " <td>14880372.0</td>\n", |
356 |
| - " <td>Asia</td>\n", |
357 |
| - " <td>38.438</td>\n", |
358 |
| - " <td>786.113360</td>\n", |
359 |
| - " <td>NaN</td>\n", |
360 |
| - " </tr>\n", |
361 |
| - " <tr>\n", |
362 |
| - " <th>4</th>\n", |
363 |
| - " <td>Afghanistan</td>\n", |
364 |
| - " <td>1982</td>\n", |
365 |
| - " <td>12881816.0</td>\n", |
366 |
| - " <td>Asia</td>\n", |
367 |
| - " <td>39.854</td>\n", |
368 |
| - " <td>978.011439</td>\n", |
369 |
| - " <td>NaN</td>\n", |
370 |
| - " </tr>\n", |
371 |
| - " </tbody>\n", |
372 |
| - "</table></div>" |
373 |
| - ], |
374 |
| - "text/plain": [ |
375 |
| - " country year pop continent lifeExp gdpPercap gniPercap\n", |
376 |
| - "0 Afghanistan 1962 10267083.0 Asia 31.997 853.100710 NaN\n", |
377 |
| - "1 Afghanistan 1967 11537966.0 Asia 34.020 836.197138 NaN\n", |
378 |
| - "2 Afghanistan 1972 13079460.0 Asia 36.088 739.981106 NaN\n", |
379 |
| - "3 Afghanistan 1977 14880372.0 Asia 38.438 786.113360 NaN\n", |
380 |
| - "4 Afghanistan 1982 12881816.0 Asia 39.854 978.011439 NaN" |
381 |
| - ] |
382 |
| - }, |
383 |
| - "execution_count": 2, |
384 |
| - "metadata": {}, |
385 |
| - "output_type": "execute_result" |
386 |
| - } |
387 |
| - ], |
388 |
| - "source": [ |
389 |
| - "df = pd.read_csv('~/Documents/GitHub/DEV/Python-Intermediate-Pilot/data/gapminder_gni.csv')\n", |
| 301 | + "execution_count": null, |
| 302 | + "metadata": {}, |
| 303 | + "outputs": [], |
| 304 | + "source": [ |
| 305 | + "import pandas as pd\n", |
| 306 | + "\n", |
| 307 | + "df = pd.read_csv('../data/gapminder_gni.csv')\n", |
390 | 308 | "df.head()"
|
391 | 309 | ]
|
392 | 310 | },
|
|
735 | 653 | "metadata": {},
|
736 | 654 | "outputs": [],
|
737 | 655 | "source": [
|
| 656 | + "import matplotlib.pyplot as plt\n", |
| 657 | + "\n", |
738 | 658 | "# YOUR CODE HERE\n",
|
739 | 659 | "\n",
|
740 | 660 | "country_list = [..., ..., ...]\n",
|
|
793 | 713 | "name": "python",
|
794 | 714 | "nbconvert_exporter": "python",
|
795 | 715 | "pygments_lexer": "ipython3",
|
796 |
| - "version": "3.8.13" |
| 716 | + "version": "3.11.7" |
797 | 717 | }
|
798 | 718 | },
|
799 | 719 | "nbformat": 4,
|
|
0 commit comments