{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "![Callysto.ca Banner](https://github.com/callysto/curriculum-notebooks/blob/master/callysto-notebook-banner-top.jpg?raw=true)\n", "\n", "\"Open" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Stats Project - Income Per Person\n", "\n", "#### by Annya Marx\n", "\n", "For this project we used secondary data from [Gapminder](https://www.gapminder.org) about [countries' gross domestic product (GDP) per person](http://gapm.io/dgdppc).\n", "\n", "## Research Question\n", "\n", "Are there more countries with a high GDP per person or a low GDP per person? How does Canada compare to other countries?\n", "\n", "## Getting Data" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
geoCountry Name18001801180218031804180518061807...2031203220332034203520362037203820392040
0afgAfghanistan603.0603.0603.0603.0603.0603.0603.0603.0...2546.02602.02657.02711.02767.02823.02880.02939.02999.03060.0
1albAlbania667.0667.0667.0667.0667.0668.0668.0668.0...19358.019781.020197.020613.021034.021463.021899.022345.022799.023263.0
2dzaAlgeria715.0716.0717.0718.0719.0720.0721.0722.0...14343.014607.014890.015188.015495.015810.016131.016459.016794.017135.0
3andAndorra1197.01199.01201.01204.01206.01208.01210.01212.0...73605.075142.076689.078256.079850.081475.083132.084823.086548.088308.0
4agoAngola618.0620.0623.0626.0628.0631.0634.0637.0...6109.06227.06352.06480.06611.06745.06883.07023.07165.07311.0
..................................................................
199africaAfrica687.0687.0688.0689.0689.0688.0690.0694.0...5660.05754.05850.05948.06048.06150.06255.06361.06470.06581.0
200asiaAsia811.0810.0808.0806.0804.0802.0800.0798.0...20113.020513.020903.021292.021683.022080.022485.022896.023316.023744.0
201europeEurope1710.01710.01723.01728.01740.01741.01746.01759.0...40132.040957.041806.042675.043564.044471.045398.046343.047308.048293.0
202americasThe Americas1382.01388.01392.01382.01377.01387.01395.01395.0...34509.035183.035883.036603.037340.038094.038864.039651.040455.041277.0
203worldWorld1003.01003.01005.01005.01006.01006.01006.01008.0...21167.021523.021877.022231.022590.022953.023322.023697.024077.024464.0
\n", "

201 rows × 243 columns

\n", "
" ], "text/plain": [ " geo Country Name 1800 1801 1802 1803 1804 1805 \\\n", "0 afg Afghanistan 603.0 603.0 603.0 603.0 603.0 603.0 \n", "1 alb Albania 667.0 667.0 667.0 667.0 667.0 668.0 \n", "2 dza Algeria 715.0 716.0 717.0 718.0 719.0 720.0 \n", "3 and Andorra 1197.0 1199.0 1201.0 1204.0 1206.0 1208.0 \n", "4 ago Angola 618.0 620.0 623.0 626.0 628.0 631.0 \n", ".. ... ... ... ... ... ... ... ... \n", "199 africa Africa 687.0 687.0 688.0 689.0 689.0 688.0 \n", "200 asia Asia 811.0 810.0 808.0 806.0 804.0 802.0 \n", "201 europe Europe 1710.0 1710.0 1723.0 1728.0 1740.0 1741.0 \n", "202 americas The Americas 1382.0 1388.0 1392.0 1382.0 1377.0 1387.0 \n", "203 world World 1003.0 1003.0 1005.0 1005.0 1006.0 1006.0 \n", "\n", " 1806 1807 ... 2031 2032 2033 2034 2035 \\\n", "0 603.0 603.0 ... 2546.0 2602.0 2657.0 2711.0 2767.0 \n", "1 668.0 668.0 ... 19358.0 19781.0 20197.0 20613.0 21034.0 \n", "2 721.0 722.0 ... 14343.0 14607.0 14890.0 15188.0 15495.0 \n", "3 1210.0 1212.0 ... 73605.0 75142.0 76689.0 78256.0 79850.0 \n", "4 634.0 637.0 ... 6109.0 6227.0 6352.0 6480.0 6611.0 \n", ".. ... ... ... ... ... ... ... ... \n", "199 690.0 694.0 ... 5660.0 5754.0 5850.0 5948.0 6048.0 \n", "200 800.0 798.0 ... 20113.0 20513.0 20903.0 21292.0 21683.0 \n", "201 1746.0 1759.0 ... 40132.0 40957.0 41806.0 42675.0 43564.0 \n", "202 1395.0 1395.0 ... 34509.0 35183.0 35883.0 36603.0 37340.0 \n", "203 1006.0 1008.0 ... 21167.0 21523.0 21877.0 22231.0 22590.0 \n", "\n", " 2036 2037 2038 2039 2040 \n", "0 2823.0 2880.0 2939.0 2999.0 3060.0 \n", "1 21463.0 21899.0 22345.0 22799.0 23263.0 \n", "2 15810.0 16131.0 16459.0 16794.0 17135.0 \n", "3 81475.0 83132.0 84823.0 86548.0 88308.0 \n", "4 6745.0 6883.0 7023.0 7165.0 7311.0 \n", ".. ... ... ... ... ... \n", "199 6150.0 6255.0 6361.0 6470.0 6581.0 \n", "200 22080.0 22485.0 22896.0 23316.0 23744.0 \n", "201 44471.0 45398.0 46343.0 47308.0 48293.0 \n", "202 38094.0 38864.0 39651.0 40455.0 41277.0 \n", "203 22953.0 23322.0 23697.0 24077.0 24464.0 \n", "\n", "[201 rows x 243 columns]" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "spreadsheet_key = '10vHiHnBQre07TwX75vTc_H1lf-w5-hbe5mZH4ro6QNE'\n", "spreadsheet_gid = '140930349'\n", "\n", "import pandas as pd\n", "csv_link = 'https://docs.google.com/spreadsheets/d/'+spreadsheet_key+'/export?gid='+spreadsheet_gid+'&format=csv'\n", "data = pd.read_csv(csv_link, skiprows=2)\n", "data = data.dropna()\n", "data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We have data for 201 countries or regions, for the years 1800 to 2040 (which includes projections).\n", "\n", "## 2019 Statistics\n", "\n", "Let's look at statistical calculations for the year 2019." ] }, { "cell_type": "code", "execution_count": 2, "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", "
2019
count201.000000
mean18896.213930
std19699.824134
min631.000000
25%3931.000000
50%12143.000000
75%28774.000000
max113331.000000
\n", "
" ], "text/plain": [ " 2019\n", "count 201.000000\n", "mean 18896.213930\n", "std 19699.824134\n", "min 631.000000\n", "25% 3931.000000\n", "50% 12143.000000\n", "75% 28774.000000\n", "max 113331.000000" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "columns = ['Country Name', '2019']\n", "data[columns].describe()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Since that doesn't include the median let's find that." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "12143.0" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data['2019'].median()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The mode is not a useful measure of central tendency here, since there are all unique values in this column." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "201" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(data['2019'].unique())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We do see a large range in the data (631 to 113331), meaning that there is a large difference between the poorest countries and riches countries in terms of GDP per person." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualizations\n", "\n", "### Bar Charts\n", "\n", "Let's create a bar chart of our sorted 2019 GDP per person data." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "alignmentgroup": "True", "hovertemplate": "Country Name=%{x}
2019=%{y}", "legendgroup": "", "marker": { "color": "#636efa" }, "name": "", "offsetgroup": "", "orientation": "v", "showlegend": false, "textposition": "auto", "type": "bar", "x": [ "Somalia", "Burundi", "Central African Republic", "Congo, Dem. Rep.", "Niger", "Liberia", "Mozambique", "Malawi", "Eritrea", "Sierra Leone", "Madagascar", "Gambia", "Togo", "Guinea-Bissau", "Haiti", "North Korea", "Chad", "Afghanistan", "Burkina Faso", "South Sudan", "Uganda", "Ethiopia", "name", "Kiribati", "Mali", "Rwanda", "Solomon Islands", "Benin", "Yemen", "Zimbabwe", "Guinea", "Comoros", "Nepal", "Vanuatu", "Syria", "Lesotho", "Tanzania", "Sao Tome and Principe", "Tajikistan", "Kenya", "Micronesia, Fed. Sts.", "Cameroon", "Senegal", "Kyrgyz Republic", "Djibouti", "Marshall Islands", "Zambia", "Tuvalu", "Mauritania", "Cote d'Ivoire", "Papua New Guinea", "Cambodia", "Bangladesh", "Ghana", "Sudan", "Nicaragua", "Honduras", "Palestine", "Africa", "Pakistan", "Congo, Rep.", "Nigeria", "Angola", "Tonga", "Samoa", "Myanmar", "Uzbekistan", "Moldova", "Cape Verde", "Lao", "Vietnam", "Timor-Leste", "Bolivia", "India", "El Salvador", "Guatemala", "Morocco", "Belize", "Guyana", "Cuba", "Philippines", "Jamaica", "Jordan", "Ukraine", "Swaziland", "Namibia", "Bhutan", "Venezuela", "Armenia", "Fiji", "Ecuador", "Dominica", "Georgia", "Tunisia", "St. Vincent and the Grenadines", "Egypt", "Lebanon", "Paraguay", "South Africa", "Indonesia", "Sri Lanka", "St. Lucia", "Albania", "Mongolia", "Peru", "Bosnia and Herzegovina", "Asia", "Nauru", "Colombia", "Macedonia, FYR", "Suriname", "Algeria", "Maldives", "Brazil", "Grenada", "Libya", "Iraq", "Costa Rica", "Iran", "Gabon", "World", "Azerbaijan", "Dominican Republic", "Barbados", "Serbia", "Botswana", "China", "Thailand", "Palau", "Argentina", "Turkmenistan", "Montenegro", "Mexico", "Belarus", "Equatorial Guinea", "Bulgaria", "Uruguay", "Mauritius", "Chile", "Panama", "Antigua and Barbuda", "Croatia", "Turkey", "Kazakhstan", "Romania", "Russia", "Greece", "Latvia", "Seychelles", "Trinidad and Tobago", "Bahamas", "St. Kitts and Nevis", "Malaysia", "The Americas", "Portugal", "Hungary", "Poland", "Estonia", "Slovak Republic", "Lithuania", "Europe", "Slovenia", "Israel", "Czech Republic", "Cyprus", "Spain", "Oman", "Italy", "New Zealand", "South Korea", "Malta", "Japan", "France", "United Kingdom", "Bahrain", "Finland", "Belgium", "Taiwan", "Canada", "Australia", "Germany", "Austria", "Sweden", "Iceland", "Saudi Arabia", "Denmark", "Netherlands", "Andorra", "United States", "Hong Kong, China", "San Marino", "Switzerland", "Monaco", "Kuwait", "United Arab Emirates", "Norway", "Brunei", "Ireland", "Singapore", "Luxembourg", "Qatar" ], "xaxis": "x", "y": [ 631, 644, 794, 838, 954, 1137, 1170, 1182, 1391, 1464, 1487, 1568, 1605, 1634, 1639, 1715, 1743, 1763, 1808, 1855, 1870, 1897, 2019, 2047, 2097, 2110, 2152, 2230, 2343, 2392, 2415, 2478, 2878, 2888, 2900, 2924, 2978, 3047, 3150, 3161, 3239, 3401, 3461, 3503, 3598, 3627, 3700, 3725, 3885, 3911, 3931, 4079, 4139, 4434, 4506, 4615, 4633, 4671, 4748, 4997, 5096, 5300, 5544, 5904, 6239, 6267, 6493, 6722, 6911, 6940, 6970, 7054, 7152, 7227, 7509, 7606, 7772, 7818, 7931, 8126, 8264, 8308, 8352, 8480, 9560, 9696, 9708, 9724, 9728, 9990, 10215, 10354, 10671, 11146, 11183, 11360, 11683, 12015, 12039, 12061, 12143, 12452, 12694, 12760, 12992, 13120, 13432, 13590, 13630, 13898, 13912, 13967, 14252, 14307, 14345, 14751, 15687, 15824, 16089, 16173, 16229, 16248, 16446, 16640, 16663, 16781, 17122, 17359, 17428, 17529, 17599, 17783, 18002, 18046, 19220, 20150, 20925, 21830, 23012, 23315, 24463, 24525, 25039, 25350, 25527, 25654, 25703, 27269, 27788, 28522, 28774, 28989, 29071, 29177, 29275, 29603, 29912, 31960, 32095, 32377, 32504, 33676, 34052, 34143, 34544, 35659, 35758, 35816, 36472, 37343, 39339, 39739, 39989, 40392, 41966, 42383, 43517, 44120, 44181, 45495, 46173, 46873, 47211, 47861, 48115, 48274, 50536, 53245, 56657, 56957, 57803, 59044, 61371, 64111, 65650, 66308, 72376, 72413, 90080, 94325, 113331 ], "yaxis": "y" } ], "layout": { "barmode": "relative", "legend": { "tracegroupgap": 0 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "2019 GDP Per Person" }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "Country Name" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "2019" } } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import plotly_express as px\n", "fig = px.bar(data.sort_values('2019'), x='Country Name', y='2019', title='2019 GDP Per Person')\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It looks like there are three countries that may be considered outliers for their high GDP per person (Qatar, Luxembourg, and Singapore). However they are probably not skewing the results significantly, and don't need to be removed before looking at central tendency and dispersion.\n", "\n", "To compare some countries, let's make a bar chart comparing 2019 GDP per person Canada to the top five and bottom five countries." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "alignmentgroup": "True", "hovertemplate": "Country Name=%{x}
2019=%{y}", "legendgroup": "", "marker": { "color": "#636efa" }, "name": "", "offsetgroup": "", "orientation": "v", "showlegend": false, "textposition": "auto", "type": "bar", "x": [ "Somalia", "Burundi", "Central African Republic", "Congo, Dem. Rep.", "Niger", "Canada", "Brunei", "Ireland", "Singapore", "Luxembourg", "Qatar" ], "xaxis": "x", "y": [ 631, 644, 794, 838, 954, 44181, 72376, 72413, 90080, 94325, 113331 ], "yaxis": "y" } ], "layout": { "barmode": "relative", "legend": { "tracegroupgap": 0 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "2019 GDP Per Person" }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "Country Name" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "2019" } } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "sorted_data = data.sort_values('2019')\n", "bottom_five = sorted_data.head()['Country Name'].tolist()\n", "top_five = sorted_data.tail()['Country Name'].tolist()\n", "countries = ['Canada']\n", "countries.extend(bottom_five)\n", "countries.extend(top_five)\n", "px.bar(sorted_data[sorted_data['Country Name'].isin(countries)], x='Country Name', y='2019', title='2019 GDP Per Person')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It looks like Canada's GDP per person is closer to the top five. Let's compare it to the mean and median." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Mean 18896.213930348258\n", "Median 12143.0\n", "Canada 44181.0\n" ] } ], "source": [ "print('Mean', data['2019'].mean())\n", "print('Median', data['2019'].median())\n", "\n", "canada_row = data[data['Country Name']=='Canada'].index[0]\n", "print('Canada', data.loc[canada_row]['2019'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can see that Canada's GDP per person is more than twice the mean value, and almost four times the median value.\n", "\n", "### Histogram\n", "\n", "Next let's create a histogram with 6 bins." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "alignmentgroup": "True", "bingroup": "x", "hovertemplate": "2019=%{x}
count=%{y}", "legendgroup": "", "marker": { "color": "#636efa" }, "name": "", "nbinsx": 6, "offsetgroup": "", "orientation": "v", "showlegend": false, "type": "histogram", "x": [ 1763, 12694, 13967, 53245, 5544, 24463, 17529, 9728, 45495, 46873, 16248, 28774, 41966, 4139, 16640, 18046, 43517, 7818, 2230, 9708, 7152, 13120, 16781, 14307, 72376, 20150, 1808, 644, 4079, 3401, 44181, 6911, 794, 1743, 23012, 17122, 13630, 2478, 838, 5096, 15824, 3911, 24525, 8126, 34544, 34143, 48274, 3598, 10354, 16446, 10215, 11360, 7509, 19220, 1391, 31960, 1897, 9990, 42383, 39989, 16173, 1568, 10671, 46173, 4434, 25703, 14345, 7606, 2415, 1634, 7931, 1639, 4633, 56957, 29603, 47861, 7227, 12061, 16089, 15687, 72413, 34052, 35816, 8308, 39739, 8352, 25350, 3161, 2047, 1715, 37343, 64111, 3503, 6940, 27269, 11683, 2924, 1137, 14751, 32377, 94325, 13898, 1487, 1182, 29071, 14252, 2097, 39339, 3627, 3885, 21830, 18002, 3239, 6722, 61371, 12760, 17783, 7772, 1170, 6267, 9696, 13590, 2878, 50536, 36472, 4615, 954, 5300, 66308, 35758, 4997, 17428, 23315, 3931, 12015, 12992, 8264, 29912, 29275, 113331, 25527, 25654, 2110, 28989, 12452, 11183, 6239, 57803, 3047, 48115, 3461, 16663, 27788, 1464, 90080, 32095, 33676, 2152, 631, 12039, 1855, 35659, 12143, 4506, 13912, 9560, 47211, 59044, 2900, 44120, 3150, 2978, 17359, 7054, 1605, 5904, 28522, 11146, 25039, 17599, 3725, 1870, 8480, 65650, 40392, 56657, 20925, 6493, 2888, 9724, 6970, 4671, 2343, 3700, 2392, 2019, 4748, 13432, 32504, 29177, 16229 ], "xaxis": "x", "yaxis": "y" } ], "layout": { "barmode": "relative", "legend": { "tracegroupgap": 0 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "Histogram of 2019 GDP Per Person" }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "2019" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "count" } } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "px.histogram(data, x='2019', nbins=6, title='Histogram of 2019 GDP Per Person')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The histogram shows that the data are not normally distributed. There are a lot more countries with a lower GDP per person than in the higher categories.\n", "\n", "## Conclusion\n", "\n", "Based on 2019 data, there are many more countries in our world with a low gross domestic product per person. Canada's GDP per person is well above average.\n", "\n", "It would be interesting to see if and how this has changed over the years, and how it is predicted to change over time." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[![Callysto.ca License](https://github.com/callysto/curriculum-notebooks/blob/master/callysto-notebook-banner-bottom.jpg?raw=true)](https://github.com/callysto/curriculum-notebooks/blob/master/LICENSE.md)" ] } ], "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.4" } }, "nbformat": 4, "nbformat_minor": 4 }