From 86c66254a0801c6c0a5b5bcd7b8e60604cebe8e7 Mon Sep 17 00:00:00 2001 From: Tomasz Dwojak Date: Thu, 14 Feb 2019 14:02:36 +0100 Subject: [PATCH] Homework 2 --- homework02/gapminder.csv | 176 +++++++++++++++ homework02/homework.ipynb | 458 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 634 insertions(+) create mode 100644 homework02/gapminder.csv create mode 100644 homework02/homework.ipynb diff --git a/homework02/gapminder.csv b/homework02/gapminder.csv new file mode 100644 index 0000000..0f2f9dc --- /dev/null +++ b/homework02/gapminder.csv @@ -0,0 +1,176 @@ +,female_BMI,male_BMI,gdp,population,under5mortality,life_expectancy,fertility +Afghanistan,21.07402,20.62058,1311.0,26528741.0,110.4,52.8,6.2 +Albania,25.65726,26.44657,8644.0,2968026.0,17.9,76.8,1.76 +Algeria,26.368409999999997,24.5962,12314.0,34811059.0,29.5,75.5,2.73 +Angola,23.48431,22.25083,7103.0,19842251.0,192.0,56.7,6.43 +Antigua and Barbuda,27.50545,25.76602,25736.0,85350.0,10.9,75.5,2.16 +Argentina,27.46523,27.5017,14646.0,40381860.0,15.4,75.4,2.24 +Armenia,27.1342,25.355420000000002,7383.0,2975029.0,20.0,72.3,1.4 +Australia,26.87777,27.56373,41312.0,21370348.0,5.2,81.6,1.96 +Austria,25.09414,26.467409999999997,43952.0,8331465.0,4.6,80.4,1.41 +Azerbaijan,27.50879,25.65117,14365.0,8868713.0,43.3,69.2,1.99 +Bahamas,29.13948,27.24594,24373.0,348587.0,14.5,72.2,1.89 +Bahrain,28.790940000000003,27.83721,42507.0,1115777.0,9.4,77.6,2.23 +Bangladesh,20.54531,20.39742,2265.0,148252473.0,55.9,68.3,2.38 +Barbados,29.221690000000002,26.384390000000003,16075.0,277315.0,15.4,75.3,1.83 +Belarus,26.641859999999998,26.16443,14488.0,9526453.0,7.2,70.0,1.42 +Belgium,25.1446,26.75915,41641.0,10779155.0,4.7,79.6,1.82 +Belize,29.81663,27.02255,8293.0,306165.0,20.1,70.7,2.91 +Benin,23.74026,22.41835,1646.0,8973525.0,116.3,59.7,5.27 +Bhutan,22.88243,22.8218,5663.0,694990.0,48.1,70.7,2.51 +Bolivia,26.8633,24.43335,5066.0,9599916.0,52.0,71.2,3.48 +Bosnia and Herzegovina,26.35874,26.611629999999998,9316.0,3839749.0,8.1,77.5,1.22 +Botswana,26.09156,22.129839999999998,13858.0,1967866.0,63.8,53.2,2.86 +Brazil,25.99113,25.78623,13906.0,194769696.0,18.6,73.2,1.9 +Brunei,22.892310000000002,24.18179,72351.0,380786.0,9.0,76.9,2.1 +Bulgaria,25.51574,26.542859999999997,15368.0,7513646.0,13.7,73.2,1.43 +Burkina Faso,21.63031,21.27157,1358.0,14709011.0,130.4,58.0,6.04 +Burundi,21.27927,21.50291,723.0,8821795.0,108.6,59.1,6.48 +Cambodia,21.69608,20.80496,2442.0,13933660.0,51.5,66.1,3.05 +Cameroon,24.9527,23.681729999999998,2571.0,19570418.0,113.8,56.6,5.17 +Canada,26.698290000000004,27.4521,41468.0,33363256.0,5.8,80.8,1.68 +Cape Verde,24.96136,23.515220000000003,6031.0,483824.0,28.4,70.4,2.57 +Chad,21.95424,21.485689999999998,1753.0,11139740.0,168.0,54.3,6.81 +Chile,27.92807,27.015420000000002,18698.0,16645940.0,8.9,78.5,1.89 +China,22.91041,22.92176,7880.0,1326690636.0,18.5,73.4,1.53 +Colombia,26.22529,24.94041,10489.0,44901660.0,19.7,76.2,2.43 +Comoros,22.444329999999997,22.06131,1440.0,665414.0,91.2,67.1,5.05 +"Congo, The Democratic Republic of the",21.6677,19.86692,607.0,61809278.0,124.5,57.5,6.45 +"Congo",23.10824,21.87134,5022.0,3832771.0,72.6,58.8,5.1 +Costa Rica,27.03497,26.47897,12219.0,4429506.0,10.3,79.8,1.91 +Ivory Coast,23.82088,22.56469,2854.0,19261647.0,116.9,55.4,4.91 +Croatia,25.17882,26.596290000000003,21873.0,4344151.0,5.9,76.2,1.43 +Cuba,26.576140000000002,25.06867,17765.0,11290239.0,6.3,77.6,1.5 +Cyprus,25.92587,27.41899,35828.0,1077010.0,4.2,80.0,1.49 +Denmark,25.106270000000002,26.13287,45017.0,5495302.0,4.3,78.9,1.89 +Djibouti,24.38177,23.38403,2502.0,809639.0,81.0,61.8,3.76 +Ecuador,27.062690000000003,25.58841,9244.0,14447600.0,26.8,74.7,2.73 +Egypt,30.099970000000003,26.732429999999997,9974.0,78976122.0,31.4,70.2,2.95 +El Salvador,27.84092,26.36751,7450.0,6004199.0,21.6,73.7,2.32 +Equatorial Guinea,24.528370000000002,23.7664,40143.0,686223.0,118.4,57.5,5.31 +Eritrea,21.082320000000003,20.885089999999998,1088.0,4500638.0,60.4,60.1,5.16 +Estonia,25.185979999999997,26.264459999999996,24743.0,1339941.0,5.5,74.2,1.62 +Ethiopia,20.71463,20.247,931.0,83079608.0,86.9,60.0,5.19 +Fiji,29.339409999999997,26.53078,7129.0,843206.0,24.0,64.9,2.74 +Finland,25.58418,26.733390000000004,42122.0,5314170.0,3.3,79.6,1.85 +France,24.82949,25.853289999999998,37505.0,62309529.0,4.3,81.1,1.97 +Gabon,25.95121,24.0762,15800.0,1473741.0,68.0,61.7,4.28 +Gambia,24.82101,21.65029,1566.0,1586749.0,87.4,65.7,5.8 +Georgia,26.45014,25.54942,5900.0,4343290.0,19.3,71.8,1.79 +Germany,25.73903,27.165090000000003,41199.0,80665906.0,4.4,80.0,1.37 +Ghana,24.33014,22.842470000000002,2907.0,23115919.0,79.9,62.0,4.19 +Greece,24.92026,26.33786,32197.0,11161755.0,4.9,80.2,1.46 +Grenada,27.31948,25.179879999999997,12116.0,103934.0,13.5,70.8,2.28 +Guatemala,26.84324,25.29947,6960.0,14106687.0,36.9,71.2,4.12 +Guinea,22.45206,22.52449,1230.0,10427356.0,121.0,57.1,5.34 +Guinea-Bissau,22.92809,21.64338,1326.0,1561293.0,127.6,53.6,5.25 +Guyana,26.470190000000002,23.68465,5208.0,748096.0,41.9,65.0,2.74 +Haiti,23.27785,23.66302,1600.0,9705130.0,83.3,61.0,3.5 +Honduras,26.73191,25.10872,4391.0,7259470.0,26.5,71.8,3.27 +"Hong Kong",23.71046,25.057470000000002,46635.0,6910384.0,3.06,82.49,1.04 +Hungary,25.97839,27.115679999999998,23334.0,10050699.0,7.2,73.9,1.33 +Iceland,26.02599,27.206870000000002,42294.0,310033.0,2.7,82.4,2.12 +India,21.31478,20.95956,3901.0,1197070109.0,65.6,64.7,2.64 +Indonesia,22.986929999999997,21.85576,7856.0,235360765.0,36.2,69.4,2.48 +Iran,27.236079999999998,25.310029999999998,15955.0,72530693.0,21.4,73.1,1.88 +Iraq,28.411170000000002,26.71017,11616.0,29163327.0,38.3,66.6,4.34 +Ireland,26.62176,27.65325,47713.0,4480145.0,4.5,80.1,2.0 +Israel,27.301920000000003,27.13151,28562.0,7093808.0,4.9,80.6,2.92 +Italy,24.79289,26.4802,37475.0,59319234.0,4.1,81.5,1.39 +Jamaica,27.22601,24.00421,8951.0,2717344.0,18.9,75.1,2.39 +Japan,21.87088,23.50004,34800.0,127317900.0,3.4,82.5,1.34 +Jordan,29.218009999999996,27.47362,10897.0,6010035.0,22.1,76.9,3.59 +Kazakhstan,26.65065,26.290779999999998,18797.0,15915966.0,25.9,67.1,2.51 +Kenya,23.06181,21.592579999999998,2358.0,38244442.0,71.0,60.8,4.76 +Kiribati,31.30769,29.2384,1803.0,98437.0,64.5,61.5,3.13 +Kuwait,31.161859999999997,29.172109999999996,91966.0,2705290.0,11.3,77.3,2.68 +Latvia,25.615129999999997,26.45693,20977.0,2144215.0,10.5,72.4,1.5 +Lebanon,27.70471,27.20117,14158.0,4109389.0,11.3,77.8,1.57 +Lesotho,26.780520000000003,21.90157,2041.0,1972194.0,114.2,44.5,3.34 +Liberia,23.21679,21.89537,588.0,3672782.0,100.9,59.9,5.19 +Libya,29.19874,26.54164,29853.0,6123022.0,18.8,75.6,2.64 +Lithuania,26.01424,26.86102,23223.0,3219802.0,8.2,72.1,1.42 +Luxembourg,26.09326,27.434040000000003,95001.0,485079.0,2.8,81.0,1.63 +Macao,24.895039999999998,25.713820000000002,80191.0,507274.0,6.72,79.32,0.94 +Macedonia,25.37646,26.34473,10872.0,2055266.0,11.8,74.5,1.47 +Madagascar,20.73501,21.403470000000002,1528.0,19926798.0,66.7,62.2,4.79 +Malawi,22.91455,22.034679999999998,674.0,13904671.0,101.1,52.4,5.78 +Malaysia,25.448320000000002,24.73069,19968.0,27197419.0,8.0,74.5,2.05 +Maldives,26.4132,23.219910000000002,12029.0,321026.0,16.0,78.5,2.38 +Mali,23.07655,21.78881,1602.0,14223403.0,148.3,58.5,6.82 +Malta,27.04993,27.683609999999998,27872.0,406392.0,6.6,80.7,1.38 +Mauritania,26.26476,22.62295,3356.0,3414552.0,103.0,67.9,4.94 +Mauritius,26.09824,25.15669,14615.0,1238013.0,15.8,72.9,1.58 +Mexico,28.737509999999997,27.42468,15826.0,114972821.0,17.9,75.4,2.35 +Micronesia,31.28402,28.10315,3197.0,104472.0,43.1,68.0,3.59 +Moldova,27.05617,24.2369,3890.0,4111168.0,17.6,70.4,1.49 +Mongolia,25.71375,24.88385,7563.0,2629666.0,34.8,64.8,2.37 +Montenegro,25.70186,26.55412,14183.0,619740.0,8.1,76.0,1.72 +Morocco,26.223090000000003,25.63182,6091.0,31350544.0,35.8,73.3,2.44 +Mozambique,23.317339999999998,21.93536,864.0,22994867.0,114.4,54.0,5.54 +Myanmar,22.47733,21.44932,2891.0,51030006.0,87.2,59.4,2.05 +Namibia,25.14988,22.65008,8169.0,2115703.0,62.2,59.1,3.36 +Nepal,20.72814,20.76344,1866.0,26325183.0,50.7,68.4,2.9 +Netherlands,25.47269,26.01541,47388.0,16519862.0,4.8,80.3,1.77 +New Zealand,27.36642,27.768929999999997,32122.0,4285380.0,6.4,80.3,2.12 +Nicaragua,27.57259,25.77291,4060.0,5594524.0,28.1,77.0,2.72 +Niger,21.95958,21.21958,843.0,15085130.0,141.3,58.0,7.59 +Nigeria,23.674020000000002,23.03322,4684.0,151115683.0,140.9,59.2,6.02 +Norway,25.73772,26.934240000000003,65216.0,4771633.0,3.6,80.8,1.96 +Oman,26.66535,26.241090000000003,47799.0,2652281.0,11.9,76.2,2.89 +Pakistan,23.44986,22.299139999999998,4187.0,163096985.0,95.5,64.1,3.58 +Panama,27.67758,26.26959,14033.0,3498679.0,21.0,77.3,2.61 +Papua New Guinea,25.77189,25.015060000000002,1982.0,6540267.0,69.7,58.6,4.07 +Paraguay,25.90523,25.54223,6684.0,6047131.0,25.7,74.0,3.06 +Peru,25.98511,24.770410000000002,9249.0,28642048.0,23.2,78.2,2.58 +Philippines,23.4671,22.872629999999997,5332.0,90297115.0,33.4,69.8,3.26 +Poland,25.918870000000002,26.6738,19996.0,38525752.0,6.7,75.4,1.33 +Portugal,26.183020000000003,26.68445,27747.0,10577458.0,4.1,79.4,1.36 +Puerto Rico,30.2212,28.378040000000002,35855.0,3728126.0,8.78,77.0,1.69 +Qatar,28.912509999999997,28.13138,126076.0,1388962.0,9.5,77.9,2.2 +Romania,25.22425,25.41069,18032.0,20741669.0,16.1,73.2,1.34 +Russia,27.21272,26.01131,22506.0,143123163.0,13.5,67.9,1.49 +Rwanda,22.07156,22.55453,1173.0,9750314.0,78.3,64.1,5.06 +Samoa,33.659079999999996,30.42475,5731.0,183440.0,18.8,72.3,4.43 +Sao Tome and Principe,24.88216,23.51233,2673.0,163595.0,61.0,66.0,4.41 +Saudi Arabia,29.598779999999998,27.884320000000002,44189.0,26742842.0,18.1,78.3,2.97 +Senegal,24.30968,21.927429999999998,2162.0,12229703.0,75.8,63.5,5.11 +Serbia,25.669970000000003,26.51495,12522.0,9109535.0,8.0,74.3,1.41 +Seychelles,27.973740000000003,25.56236,20065.0,91634.0,14.2,72.9,2.28 +Sierra Leone,23.93364,22.53139,1289.0,5521838.0,179.1,53.6,5.13 +Singapore,22.86642,23.83996,65991.0,4849641.0,2.8,80.6,1.28 +Slovak Republic,26.323729999999998,26.92717,24670.0,5396710.0,8.8,74.9,1.31 +Slovenia,26.582140000000003,27.43983,30816.0,2030599.0,3.7,78.7,1.43 +Solomon Islands,28.8762,27.159879999999998,1835.0,503410.0,33.1,62.3,4.36 +Somalia,22.66607,21.969170000000002,615.0,9132589.0,168.5,52.6,7.06 +South Africa,29.4803,26.85538,12263.0,50348811.0,66.1,53.4,2.54 +Spain,26.30554,27.49975,34676.0,45817016.0,5.0,81.1,1.42 +Sri Lanka,23.11717,21.96671,6907.0,19949553.0,11.7,74.0,2.32 +Sudan,23.16132,22.40484,3246.0,34470138.0,84.7,65.5,4.79 +Suriname,27.749859999999998,25.49887,13470.0,506657.0,26.4,70.2,2.41 +Swaziland,28.448859999999996,23.16969,5887.0,1153750.0,112.2,45.1,3.7 +Sweden,25.1466,26.37629,43421.0,9226333.0,3.2,81.1,1.92 +Switzerland,24.07242,26.20195,55020.0,7646542.0,4.7,82.0,1.47 +Syria,28.87418,26.919690000000003,6246.0,20097057.0,16.5,76.1,3.17 +Tajikistan,23.84799,23.77966,2001.0,7254072.0,56.2,69.6,3.7 +Tanzania,23.0843,22.47792,2030.0,42844744.0,72.4,60.4,5.54 +Thailand,24.38577,23.008029999999998,12216.0,66453255.0,15.6,73.9,1.48 +Togo,22.73858,21.87875,1219.0,6052937.0,96.4,57.5,4.88 +Tonga,34.25969,30.99563,4748.0,102816.0,17.0,70.3,4.01 +Trinidad and Tobago,28.27587,26.396690000000003,30875.0,1315372.0,24.9,71.7,1.8 +Tunisia,27.93706,25.15699,9938.0,10408091.0,19.4,76.8,2.04 +Turkey,28.247490000000003,26.703709999999997,16454.0,70344357.0,22.2,77.8,2.15 +Turkmenistan,24.66154,25.24796,8877.0,4917541.0,63.9,67.2,2.48 +Uganda,22.48126,22.35833,1437.0,31014427.0,89.3,56.0,6.34 +Ukraine,26.23317,25.42379,8762.0,46028476.0,12.9,67.8,1.38 +United Arab Emirates,29.614009999999997,28.053590000000003,73029.0,6900142.0,9.1,75.6,1.95 +United Kingdom,26.944490000000002,27.392490000000002,37739.0,61689620.0,5.6,79.7,1.87 +United States,28.343590000000003,28.456979999999998,50384.0,304473143.0,7.7,78.3,2.07 +Uruguay,26.593040000000002,26.39123,15317.0,3350832.0,13.0,76.0,2.11 +Uzbekistan,25.43432,25.32054,3733.0,26952719.0,49.2,69.6,2.46 +Vanuatu,28.458759999999998,26.78926,2944.0,225335.0,28.2,63.4,3.61 +Venezuela,28.134079999999997,27.445,17911.0,28116716.0,17.1,74.2,2.53 +Vietnam,21.065,20.9163,4085.0,86589342.0,26.2,74.1,1.86 +Palestine,29.026429999999998,26.5775,3564.0,3854667.0,24.7,74.1,4.38 +Zambia,23.05436,20.68321,3039.0,13114579.0,94.9,51.1,5.88 +Zimbabwe,24.645220000000002,22.0266,1286.0,13495462.0,98.3,47.3,3.85 diff --git a/homework02/homework.ipynb b/homework02/homework.ipynb new file mode 100644 index 0000000..b4f3dde --- /dev/null +++ b/homework02/homework.ipynb @@ -0,0 +1,458 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Python: Drugie zadanie domowe" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Drugie zadanie domowe będzie polegać na opracowaniu danych zawartych w pliku `gapminder.csv`, który znajduje się w tym katalogu (proszę wykorzystać ten plik, a nie ten w katalogu labs04). Ten arkusz poprowadzi Cię krok po kroku po zadaniu domowym." + ] + }, + { + "cell_type": "code", + "execution_count": 97, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import matplotlib.pyplot as plt\n", + "%matplotlib inline" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**zad. 1** Wczytaj dane do zmiennej `data`, w taki sposób, żeby nazwa Państwa była kluczem." + ] + }, + { + "cell_type": "code", + "execution_count": 86, + "metadata": {}, + "outputs": [], + "source": [ + "data = pd.read_csv(\"gapminder.csv\", index_col=0)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**zad. 2** Znajdź najbardziej i najmniej zaludnione państwa na świecie." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**zad. 3** W ilu państwach współczynnik `female_BMI` jest większy od `male_BMI`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**zad. 4**\n", + " 1. Zainstaluj bibliotekę `pycountry_convert` i zaimportuj ją.\n", + " 1. Dodaj do danych kolumnę `continent`, która będzie zawierać nazwę kontynentu, na którym jest położone dane państwo. Wykorzystaj bibliotekę `pycountry_convert`. *Uwaga*: trzeba najpierw uzystać kod państwa w fomacie ISO-2, następnie uzystkać kod kontynentu, a na końcu uzyskać nazwę kontynentu." + ] + }, + { + "cell_type": "code", + "execution_count": 92, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Afghanistan Asia\n", + "Albania Europe\n", + "Algeria Africa\n", + "Angola Africa\n", + "Antigua and Barbuda North America\n", + "Argentina South America\n", + "Armenia Asia\n", + "Australia Oceania\n", + "Austria Europe\n", + "Azerbaijan Asia\n", + "Bahamas North America\n", + "Bahrain Asia\n", + "Bangladesh Asia\n", + "Barbados North America\n", + "Belarus Europe\n", + "Belgium Europe\n", + "Belize North America\n", + "Benin Africa\n", + "Bhutan Asia\n", + "Bolivia South America\n", + "Bosnia and Herzegovina Europe\n", + "Botswana Africa\n", + "Brazil South America\n", + "Brunei Asia\n", + "Bulgaria Europe\n", + "Burkina Faso Africa\n", + "Burundi Africa\n", + "Cambodia Asia\n", + "Cameroon Africa\n", + "Canada North America\n", + " ... \n", + "Spain Europe\n", + "Sri Lanka Asia\n", + "Sudan Africa\n", + "Suriname South America\n", + "Swaziland Africa\n", + "Sweden Europe\n", + "Switzerland Europe\n", + "Syria Asia\n", + "Tajikistan Asia\n", + "Tanzania Africa\n", + "Thailand Asia\n", + "Togo Africa\n", + "Tonga Oceania\n", + "Trinidad and Tobago North America\n", + "Tunisia Africa\n", + "Turkey Asia\n", + "Turkmenistan Asia\n", + "Uganda Africa\n", + "Ukraine Europe\n", + "United Arab Emirates Asia\n", + "United Kingdom Europe\n", + "United States North America\n", + "Uruguay South America\n", + "Uzbekistan Asia\n", + "Vanuatu Oceania\n", + "Venezuela South America\n", + "Vietnam Asia\n", + "Palestine Asia\n", + "Zambia Africa\n", + "Zimbabwe Africa\n", + "Name: continent, Length: 175, dtype: object" + ] + }, + "execution_count": 92, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "conts = []\n", + "for name in data.index:\n", + " country_code = pycountry_convert.convert_countries.country_name_to_country_alpha2(name)\n", + " cont_code = pycountry_convert.convert_country_alpha2_to_continent_code.country_alpha2_to_continent_code(country_code)\n", + " cont = pycountry_convert.convert_continent_code_to_continent_name(cont_code)\n", + " conts.append(cont)\n", + " \n", + "data['continent'] = conts\n", + "data['continent']" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**zad. 5**\n", + "Oblicz ile osób mieszka na każdym z kontynentów." + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
female_BMImale_BMIgdppopulationunder5mortalitylife_expectancyfertility
continent
Africa1259.332131181.44512280335.09.772803e+084763.003136.10246.50
Asia1114.287651084.745981038232.03.949400e+091302.983201.41108.48
Europe980.309781009.608771173410.07.219954e+08273.602929.3059.56
North America526.06040497.74034338430.05.235798e+08392.381412.2045.00
Oceania297.20093279.58957102803.03.425711e+07310.00683.2034.02
South America322.37322308.59791139888.03.881582e+08288.70886.8030.10
\n", + "
" + ], + "text/plain": [ + " female_BMI male_BMI gdp population \\\n", + "continent \n", + "Africa 1259.33213 1181.44512 280335.0 9.772803e+08 \n", + "Asia 1114.28765 1084.74598 1038232.0 3.949400e+09 \n", + "Europe 980.30978 1009.60877 1173410.0 7.219954e+08 \n", + "North America 526.06040 497.74034 338430.0 5.235798e+08 \n", + "Oceania 297.20093 279.58957 102803.0 3.425711e+07 \n", + "South America 322.37322 308.59791 139888.0 3.881582e+08 \n", + "\n", + " under5mortality life_expectancy fertility \n", + "continent \n", + "Africa 4763.00 3136.10 246.50 \n", + "Asia 1302.98 3201.41 108.48 \n", + "Europe 273.60 2929.30 59.56 \n", + "North America 392.38 1412.20 45.00 \n", + "Oceania 310.00 683.20 34.02 \n", + "South America 288.70 886.80 30.10 " + ] + }, + "execution_count": 103, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.groupby('continent').sum()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**zad. 6** Narysyj wykres słupkowy pokazujący ile państw leży na każdym z kontynentów." + ] + }, + { + "cell_type": "code", + "execution_count": 102, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 102, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAE7CAYAAADNbXrqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cG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TsGOjSGCV59c95uarqv02smPF6BXBxkhvoZrocCDQ9VXMpcshFGqMkL5uj+b50U/oeUFW7T7iksUlyH+AR/e61VXX3z3u/Rs9AlyYkyf2AU+nC/EzgjVV167BVLU6SxwLfqKpv9vu/Q3fb/43An1XVd4esb7lxlos0Zkn2TvJa4Cq6Yc4jquqV0x7mvbcDPwZI8iTg9cB7gO8B6wasa1lyDF0aoyR/ARxPF26HVNX3By5p1HacdRb+HGBdVZ0NnJ3kygHrWpYccpHGKMm9wN10t8PP/mEL3UXRPQYpbESSfAk4rKo2JbkGWFtVn5p5raoePWyFy4tn6NIYVVXrw5rvBz6Z5NvAD+nWqCHJw+iGXTRBnqFLWpQkRwL7ARdU1V1928OB3avq8kGLW2YMdElqROu/DkrSsmGgS1IjDHRJaoSBLkmNMNAlqRH/H0B3xVUsRwwUAAAAAElFTkSuQmCC\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "data.continent.value_counts().plot('bar')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**zad. 7** \n", + " * Kolumna `gdp` zawiera informacje o PKB na obywatela. Stwórz nową kolumnę `gdp_total`, która będzie informować o PKB danego kraju.\n", + " * Oblicz ile wynosi suma światowego PKB (kolumna `gdp_total`).\n", + " * Oblicz ile krajów jest odpowiedzialnych za wytworzenie 80% światego PKB." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**zad. 8** Wyświetl wszystkie europejskie państwa, w których oczekiwana długość życia wynosi conajmniej 80 lat. " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**zad. 9** Znajdź państwo, które ma najbardziej zbliżone PKB do Polski. Spróbuj rozwiązać to zadanie w jednej linijce." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**zad. 10 (ostatnie)**\n", + " * Zobacz czy masz zainstalowaną bibliotekę `requests`, która sluży do wykonywania zapytań HTTP. Jeżeli nie, to zainstaluj ją. \n", + " * Uruchom z funkcję `requests.get` podając jako argument link: `https://aws.random.cat/meow`. Wynik zapisz do zmiennej response.\n", + " * Wykonaj metodę `json()` na zmiennej `response` która zwróci Ci słownik, w którym będzie klucz `file`. Zapisz wartość `file` do zmiennej `url`.\n", + " * Zaimportuj `Image` i `display` z biblioteki `from IPython.core.display`.\n", + " * Stwórz obiekt Image podając w konstruktorze zmienną `url`,a wynik zapisz do `image`.\n", + " * Wykonaj funkcję `display` na obiekcie `image`.\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}