From 074f6d556b264d22a68ec705339dba34e11d79e5 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 25 Sep 2021 22:02:51 -0400 Subject: [PATCH] Added new charts --- exploratory_data_analysis_olympics_2021.ipynb | 1395 +++++++++++++++-- 1 file changed, 1281 insertions(+), 114 deletions(-) diff --git a/exploratory_data_analysis_olympics_2021.ipynb b/exploratory_data_analysis_olympics_2021.ipynb index cd70c9e..3373a63 100644 --- a/exploratory_data_analysis_olympics_2021.ipynb +++ b/exploratory_data_analysis_olympics_2021.ipynb @@ -59,29 +59,29 @@ "output_type": "stream", "text": [ "Requirement already satisfied: geopandas in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (0.9.0)\n", - "Requirement already satisfied: pyproj>=2.2.0 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from geopandas) (3.2.0)\n", + "Requirement already satisfied: fiona>=1.8 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from geopandas) (1.8.20)\n", "Requirement already satisfied: shapely>=1.6 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from geopandas) (1.7.1)\n", + "Requirement already satisfied: pyproj>=2.2.0 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from geopandas) (3.2.0)\n", "Requirement already satisfied: pandas>=0.24.0 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from geopandas) (1.2.4)\n", - "Requirement already satisfied: fiona>=1.8 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from geopandas) (1.8.20)\n", - "Requirement already satisfied: click>=4.0 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (7.1.2)\n", - "Requirement already satisfied: munch in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (2.5.0)\n", "Requirement already satisfied: certifi in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (2020.12.5)\n", + "Requirement already satisfied: setuptools in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (52.0.0.post20210125)\n", + "Requirement already satisfied: click>=4.0 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (7.1.2)\n", + "Requirement already satisfied: six>=1.7 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (1.15.0)\n", "Requirement already satisfied: cligj>=0.5 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (0.7.2)\n", - "Requirement already satisfied: attrs>=17 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (20.3.0)\n", "Requirement already satisfied: click-plugins>=1.0 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (1.1.1)\n", - "Requirement already satisfied: six>=1.7 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (1.15.0)\n", - "Requirement already satisfied: setuptools in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (52.0.0.post20210125)\n", + "Requirement already satisfied: munch in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (2.5.0)\n", + "Requirement already satisfied: attrs>=17 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from fiona>=1.8->geopandas) (20.3.0)\n", "Requirement already satisfied: python-dateutil>=2.7.3 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from pandas>=0.24.0->geopandas) (2.8.1)\n", "Requirement already satisfied: pytz>=2017.3 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from pandas>=0.24.0->geopandas) (2021.1)\n", "Requirement already satisfied: numpy>=1.16.5 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from pandas>=0.24.0->geopandas) (1.20.1)\n", "Requirement already satisfied: wordcloud in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (1.8.1)\n", - "Requirement already satisfied: matplotlib in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from wordcloud) (3.3.4)\n", "Requirement already satisfied: numpy>=1.6.1 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from wordcloud) (1.20.1)\n", + "Requirement already satisfied: matplotlib in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from wordcloud) (3.3.4)\n", "Requirement already satisfied: pillow in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from wordcloud) (8.2.0)\n", "Requirement already satisfied: python-dateutil>=2.1 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from matplotlib->wordcloud) (2.8.1)\n", "Requirement already satisfied: cycler>=0.10 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from matplotlib->wordcloud) (0.10.0)\n", - "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from matplotlib->wordcloud) (2.4.7)\n", "Requirement already satisfied: kiwisolver>=1.0.1 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from matplotlib->wordcloud) (1.3.1)\n", + "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from matplotlib->wordcloud) (2.4.7)\n", "Requirement already satisfied: six in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from cycler>=0.10->matplotlib->wordcloud) (1.15.0)\n", "Requirement already satisfied: plotly in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (5.3.1)\n", "Requirement already satisfied: six in /Users/anonymous/opt/anaconda3/lib/python3.8/site-packages (from plotly) (1.15.0)\n", @@ -139,7 +139,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 33, "id": "0a806733", "metadata": {}, "outputs": [ @@ -164,8 +164,8 @@ }, { "cell_type": "code", - "execution_count": 53, - "id": "2de38bb3", + "execution_count": 4, + "id": "29f768b2", "metadata": {}, "outputs": [ { @@ -238,7 +238,7 @@ "ABALDE Tamara Spain Basketball" ] }, - "execution_count": 53, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -249,8 +249,8 @@ }, { "cell_type": "code", - "execution_count": 51, - "id": "9ad3fe1e", + "execution_count": 5, + "id": "7e5bb396", "metadata": {}, "outputs": [ { @@ -323,7 +323,7 @@ "ZYZANSKA Sylwia Poland Archery" ] }, - "execution_count": 51, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -334,8 +334,8 @@ }, { "cell_type": "code", - "execution_count": 54, - "id": "c920246d", + "execution_count": 6, + "id": "22884dc6", "metadata": {}, "outputs": [ { @@ -415,7 +415,7 @@ "AGEBA Yuya Japan Volleyball NaN" ] }, - "execution_count": 54, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -426,8 +426,8 @@ }, { "cell_type": "code", - "execution_count": 55, - "id": "0fe28cb4", + "execution_count": 7, + "id": "e436cbb3", "metadata": {}, "outputs": [ { @@ -507,7 +507,7 @@ "ZONDI Nkuliso South Africa Hockey Women" ] }, - "execution_count": 55, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -518,8 +518,8 @@ }, { "cell_type": "code", - "execution_count": 56, - "id": "c0f52de9", + "execution_count": 8, + "id": "4c1ea4e0", "metadata": {}, "outputs": [ { @@ -599,7 +599,7 @@ "Athletics 969 1072 2041" ] }, - "execution_count": 56, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -610,17 +610,10 @@ }, { "cell_type": "code", - "execution_count": 63, - "id": "8f9baed1", + "execution_count": 9, + "id": "ebbaecc2", "metadata": {}, "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Index(['Female', 'Male', 'Total'], dtype='object')\n" - ] - }, { "data": { "text/html": [ @@ -698,7 +691,7 @@ "Wrestling 96 193 289" ] }, - "execution_count": 63, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -709,8 +702,8 @@ }, { "cell_type": "code", - "execution_count": 58, - "id": "e695d5e3", + "execution_count": 10, + "id": "69244a51", "metadata": {}, "outputs": [ { @@ -811,7 +804,7 @@ "5 ROC 20 28 23 71 3" ] }, - "execution_count": 58, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -822,8 +815,8 @@ }, { "cell_type": "code", - "execution_count": 59, - "id": "8411322e", + "execution_count": 11, + "id": "83372b65", "metadata": {}, "outputs": [ { @@ -867,7 +860,7 @@ " \n", " \n", " 86\n", - " Others\n", + " Ghana\n", " 0\n", " 0\n", " 1\n", @@ -876,7 +869,7 @@ " \n", " \n", " 86\n", - " Others\n", + " Grenada\n", " 0\n", " 0\n", " 1\n", @@ -885,7 +878,7 @@ " \n", " \n", " 86\n", - " Others\n", + " Kuwait\n", " 0\n", " 0\n", " 1\n", @@ -894,7 +887,7 @@ " \n", " \n", " 86\n", - " Others\n", + " Republic of Moldova\n", " 0\n", " 0\n", " 1\n", @@ -903,7 +896,7 @@ " \n", " \n", " 86\n", - " Others\n", + " Syrian Arab Republic\n", " 0\n", " 0\n", " 1\n", @@ -915,16 +908,16 @@ "" ], "text/plain": [ - " Team/NOC Gold Silver Bronze Total Rank by Total\n", - "Rank \n", - "86 Others 0 0 1 1 77\n", - "86 Others 0 0 1 1 77\n", - "86 Others 0 0 1 1 77\n", - "86 Others 0 0 1 1 77\n", - "86 Others 0 0 1 1 77" + " Team/NOC Gold Silver Bronze Total Rank by Total\n", + "Rank \n", + "86 Ghana 0 0 1 1 77\n", + "86 Grenada 0 0 1 1 77\n", + "86 Kuwait 0 0 1 1 77\n", + "86 Republic of Moldova 0 0 1 1 77\n", + "86 Syrian Arab Republic 0 0 1 1 77" ] }, - "execution_count": 59, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -935,8 +928,8 @@ }, { "cell_type": "code", - "execution_count": 60, - "id": "31294897", + "execution_count": 12, + "id": "4f816b66", "metadata": {}, "outputs": [ { @@ -1016,7 +1009,7 @@ "Italy 3x3 Basketball Italy Women" ] }, - "execution_count": 60, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -1027,8 +1020,8 @@ }, { "cell_type": "code", - "execution_count": 61, - "id": "e214a34a", + "execution_count": 13, + "id": "1a5a222b", "metadata": {}, "outputs": [ { @@ -1108,7 +1101,7 @@ "United States Water Polo United States of America Women" ] }, - "execution_count": 61, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -1119,7 +1112,7 @@ }, { "cell_type": "markdown", - "id": "499d3f03", + "id": "47645dba", "metadata": {}, "source": [ "**Detailed information about dataset**" @@ -1127,8 +1120,8 @@ }, { "cell_type": "code", - "execution_count": 67, - "id": "b7018122", + "execution_count": 14, + "id": "b4e5f965", "metadata": {}, "outputs": [ { @@ -1212,7 +1205,7 @@ }, { "cell_type": "markdown", - "id": "16f90c99", + "id": "cc073bdf", "metadata": {}, "source": [ "**General Statistics of the data**" @@ -1220,8 +1213,8 @@ }, { "cell_type": "code", - "execution_count": 68, - "id": "2ea859b6", + "execution_count": 15, + "id": "4a78b194", "metadata": {}, "outputs": [ { @@ -1282,7 +1275,7 @@ "freq 615 2068" ] }, - "execution_count": 68, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -1293,8 +1286,8 @@ }, { "cell_type": "code", - "execution_count": 69, - "id": "c94bd098", + "execution_count": 16, + "id": "a01d39d2", "metadata": {}, "outputs": [ { @@ -1360,7 +1353,7 @@ "freq 35 74 94" ] }, - "execution_count": 69, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -1371,8 +1364,8 @@ }, { "cell_type": "code", - "execution_count": 70, - "id": "c630f4b1", + "execution_count": 17, + "id": "dc237781", "metadata": {}, "outputs": [ { @@ -1466,7 +1459,7 @@ "max 969.000000 1072.000000 2041.00000" ] }, - "execution_count": 70, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -1477,8 +1470,8 @@ }, { "cell_type": "code", - "execution_count": 72, - "id": "b7272d20", + "execution_count": 18, + "id": "3ef130be", "metadata": {}, "outputs": [ { @@ -1590,7 +1583,7 @@ "max 39.000000 41.000000 33.000000 113.000000 77.000000" ] }, - "execution_count": 72, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -1601,8 +1594,8 @@ }, { "cell_type": "code", - "execution_count": 74, - "id": "a4904461", + "execution_count": 19, + "id": "3f25ce7f", "metadata": {}, "outputs": [ { @@ -1668,7 +1661,7 @@ "freq 113 48 120" ] }, - "execution_count": 74, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -1687,7 +1680,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 20, "id": "7662ce25", "metadata": {}, "outputs": [], @@ -1708,7 +1701,7 @@ }, { "cell_type": "markdown", - "id": "b09a3048", + "id": "a23ce6f5", "metadata": {}, "source": [ "**Checking for null values**" @@ -1716,8 +1709,8 @@ }, { "cell_type": "code", - "execution_count": 89, - "id": "ab8ad250", + "execution_count": 21, + "id": "7e7f8107", "metadata": {}, "outputs": [ { @@ -1742,8 +1735,8 @@ }, { "cell_type": "code", - "execution_count": 135, - "id": "64cd3d56", + "execution_count": 22, + "id": "daca122c", "metadata": {}, "outputs": [ { @@ -1868,7 +1861,7 @@ "[394 rows x 3 columns]" ] }, - "execution_count": 135, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } @@ -1881,7 +1874,7 @@ }, { "cell_type": "markdown", - "id": "d448f70b", + "id": "8cdfdc35", "metadata": {}, "source": [ "**Checking for null values again**" @@ -1889,8 +1882,8 @@ }, { "cell_type": "code", - "execution_count": 137, - "id": "732300e2", + "execution_count": 23, + "id": "41fe4707", "metadata": {}, "outputs": [ { @@ -1917,7 +1910,7 @@ }, { "cell_type": "markdown", - "id": "aa563982", + "id": "a41583b2", "metadata": {}, "source": [ "### Athletes " @@ -1933,7 +1926,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 24, "id": "ae319856", "metadata": {}, "outputs": [ @@ -1943,7 +1936,7 @@ "Text(0.5, 1.0, 'Number of Athletes by Country')" ] }, - "execution_count": 5, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" }, @@ -1987,7 +1980,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 25, "id": "69d7d28f", "metadata": { "scrolled": true @@ -2020,7 +2013,7 @@ }, { "cell_type": "markdown", - "id": "c12bfd54", + "id": "af6605cc", "metadata": {}, "source": [ "We can see that USA has the maximum number of athletes participating in the olympics." @@ -2028,7 +2021,7 @@ }, { "cell_type": "markdown", - "id": "8f6e1cb3", + "id": "084b78d8", "metadata": {}, "source": [ "**Participation of players in different games**" @@ -2036,14 +2029,14 @@ }, { "cell_type": "code", - "execution_count": 138, - "id": "db14ddb2", + "execution_count": 26, + "id": "8a6f42fb", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ - "0500100015002000Cycling BMX FreestyleTrampoline GymnasticsSport ClimbingSurfingCycling BMX RacingMarathon Swimming3x3 BasketballModern PentathlonCycling Mountain BikeKarateSkateboardingCanoe SlalomBeach VolleyballRhythmic GymnasticsArtistic SwimmingTriathlonGolfArcheryTaekwondoDivingTable TennisBadmintonTennisArtistic GymnasticsWeightliftingCycling RoadCycling TrackBaseball/SoftballCanoe SprintEquestrianFencingWater PoloBoxingVolleyballWrestlingBasketballRugby SevensSailingShootingHandballJudoHockeyRowingFootballSwimmingAthleticsParticipation of players in different gamesTotal player countName of the game" + "0500100015002000Cycling BMX FreestyleTrampoline GymnasticsSport ClimbingSurfingCycling BMX RacingMarathon Swimming3x3 BasketballModern PentathlonCycling Mountain BikeKarateSkateboardingCanoe SlalomBeach VolleyballRhythmic GymnasticsArtistic SwimmingTriathlonGolfArcheryTaekwondoDivingBadmintonTable TennisTennisWeightliftingArtistic GymnasticsCycling RoadCycling TrackBaseball/SoftballCanoe SprintEquestrianFencingWater PoloBoxingVolleyballWrestlingBasketballRugby SevensSailingShootingHandballJudoHockeyRowingFootballSwimmingAthleticsParticipation of players in different gamesTotal player countName of the game" ] }, "metadata": {}, @@ -2068,7 +2061,7 @@ }, { "cell_type": "markdown", - "id": "1eb43b3d", + "id": "b63746ed", "metadata": {}, "source": [ "### GENDER" @@ -2084,14 +2077,14 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 27, "id": "f2a14657", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ - "0%20%40%60%80%100%3x3 BasketballArcheryArtistic GymnasticsArtistic SwimmingAthleticsBadmintonBaseball/SoftballBasketballBeach VolleyballBoxingCanoe SlalomCanoe SprintCycling BMX FreestyleCycling BMX RacingCycling Mountain BikeCycling RoadCycling TrackDivingEquestrianFencingFootballGolfHandballHockeyJudoKarateMarathon SwimmingModern PentathlonRhythmic GymnasticsRowingRugby SevensSailingShootingSkateboardingSport ClimbingSurfingSwimmingTable TennisTaekwondoTennisTrampoline GymnasticsTriathlonVolleyballWater PoloWeightliftingWrestlingMalesFemalesGames Distribution based on gender" + "0%20%40%60%80%100%3x3 BasketballArcheryArtistic GymnasticsArtistic SwimmingAthleticsBadmintonBaseball/SoftballBasketballBeach VolleyballBoxingCanoe SlalomCanoe SprintCycling BMX FreestyleCycling BMX RacingCycling Mountain BikeCycling RoadCycling TrackDivingEquestrianFencingFootballGolfHandballHockeyJudoKarateMarathon SwimmingModern PentathlonRhythmic GymnasticsRowingRugby SevensSailingShootingSkateboardingSport ClimbingSurfingSwimmingTable TennisTaekwondoTennisTrampoline GymnasticsTriathlonVolleyballWater PoloWeightliftingWrestlingMalesFemalesGames Distribution based on gender" ] }, "metadata": {}, @@ -2144,7 +2137,7 @@ }, { "cell_type": "markdown", - "id": "f6055eeb", + "id": "4cc734e1", "metadata": {}, "source": [ "### MEDALS" @@ -2160,14 +2153,14 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 34, "id": "dd03ef2a", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ - "32.6%10.5%8.15%6.57%6.02%5.37%4.26%3.7%3.43%3.33%3.06%2.22%1.94%1.85%1.85%1.85%1.76%1.57%OthersUnited States of AmericaPeople's Republic of ChinaROCGreat BritainJapanAustraliaItalyGermanyNetherlandsFranceCanadaBrazilNew ZealandHungaryRepublic of KoreaUkraineSpainMedal won by Country" + "32.6%10.5%8.15%6.57%6.02%5.37%4.26%3.7%3.43%3.33%3.06%2.22%1.94%1.85%1.85%1.85%1.76%1.57%OthersUnited States of AmericaPeople's Republic of ChinaROCGreat BritainJapanAustraliaItalyGermanyNetherlandsFranceCanadaBrazilNew ZealandHungaryRepublic of KoreaUkraineSpainMedal won by Country" ] }, "metadata": {}, @@ -2175,14 +2168,15 @@ } ], "source": [ - "medals.loc[medals['Total']<=15,'Team/NOC']='Others'\n", - "fig = px.pie(medals, values='Total', names='Team/NOC', title='Medal won by Country', height=600) \n", + "medals_pie = medals.copy()\n", + "medals_pie.loc[medals_pie['Total']<=15,'Team/NOC']='Others'\n", + "fig = px.pie(medals_pie, values='Total', names='Team/NOC', title='Medal won by Country', height=600) \n", "fig.show('svg')" ] }, { "cell_type": "markdown", - "id": "02d1ab27", + "id": "8cf27526", "metadata": {}, "source": [ "From above Pie chart we can infer that USA won highest number of medals followed by China and Russia" @@ -2190,14 +2184,14 @@ }, { "cell_type": "code", - "execution_count": 171, - "id": "9ef7d42e", + "execution_count": 29, + "id": "133d574c", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ - "0200400600United States of AmericaJapanAustraliaPeople's Republic of ChinaGermanyFranceCanadaGreat BritainItalySpainROCBrazilNetherlandsRepublic of KoreaNew ZealandPolandArgentinaSouth AfricaMexicoHungaryUkraineEgyptSwedenBelgiumCzech RepublicIndiaIrelandSwitzerlandBelarusDenmarkTurkeyRomaniaKazakhstanNorwayPortugalIsraelSerbiaKenyaGreeceAustriaCubaChinese TaipeiIslamic Republic of IranColombiaUzbekistanDominican RepublicJamaicaNigeriaCroatiaTunisiaChileSloveniaMoroccoEcuadorFinlandVenezuelaMongoliaEthiopiaBulgariaAzerbaijanAlgeriavariableNo of AthletesNo of CoachesMedalsSum of valuesCountries" + "0200400600United States of AmericaJapanAustraliaChinaGermanyFranceCanadaGreat BritainItalySpainRussiaBrazilNetherlandsRepublic of KoreaNew ZealandPolandArgentinaSouth AfricaHungaryMexicoUkraineEgyptSwedenBelgiumCzech RepublicIndiaIrelandSwitzerlandBelarusDenmarkTurkeyRomaniaKazakhstanNorwayPortugalIsraelSerbiaKenyaGreeceAustriaCubaChinese TaipeiIranColombiaUzbekistanDominican RepublicJamaicaNigeriaTunisiaCroatiaChileSloveniaMoroccoEcuadorFinlandVenezuelaMongoliaEthiopiaAlgeriaAzerbaijanBulgariavariableNo of AthletesNo of CoachesMedalsSum of valuesCountries" ] }, "metadata": {}, @@ -2238,7 +2232,7 @@ }, { "cell_type": "markdown", - "id": "84744841", + "id": "af6b5094", "metadata": {}, "source": [ "**From above chart we get a lot of information if we look at the pattern closely**\n", @@ -2249,13 +2243,1186 @@ "4. China has earned more number of medals than Australia despite of having less number of coaches and athletes than Australia\n" ] }, + { + "cell_type": "markdown", + "id": "50491f83", + "metadata": {}, + "source": [ + "**Medals earned by participated countries**" + ] + }, { "cell_type": "code", - "execution_count": null, - "id": "dc69b71f", + "execution_count": 74, + "id": "1ca764cb", "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "marker": { + "color": "rgb(255,215,0)", + "line": { + "color": "rgba(0, 0, 0, 0.5)" + } + }, + "name": "Gold", + "type": "bar", + "x": [ + "United States of America", + "People's Republic of China", + "Japan", + "Great Britain", + "ROC", + "Australia", + "Netherlands", + "France", + "Germany", + "Italy", + "Canada", + "Brazil", + "New Zealand", + "Cuba", + "Hungary", + "Republic of Korea", + "Poland", + "Czech Republic", + "Kenya", + "Norway", + "Jamaica", + "Spain", + "Sweden", + "Switzerland", + "Denmark", + "Croatia", + "Islamic Republic of Iran", + "Serbia", + "Belgium", + "Bulgaria" + ], + "y": [ + 39, + 38, + 27, + 22, + 20, + 17, + 10, + 10, + 10, + 10, + 7, + 7, + 7, + 7, + 6, + 6, + 4, + 4, + 4, + 4, + 4, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3 + ] + }, + { + "marker": { + "color": "rgb(192,192,192)", + "line": { + "color": "rgba(0, 0, 0, 0.5)" + } + }, + "name": "Silver", + "type": "bar", + "x": [ + "United States of America", + "People's Republic of China", + "Japan", + "Great Britain", + "ROC", + "Australia", + "Netherlands", + "France", + "Germany", + "Italy", + "Canada", + "Brazil", + "New Zealand", + "Cuba", + "Hungary", + "Republic of Korea", + "Poland", + "Czech Republic", + "Kenya", + "Norway", + "Jamaica", + "Spain", + "Sweden", + "Switzerland", + "Denmark", + "Croatia", + "Islamic Republic of Iran", + "Serbia", + "Belgium", + "Bulgaria" + ], + "y": [ + 41, + 32, + 14, + 21, + 28, + 7, + 12, + 12, + 11, + 10, + 6, + 6, + 6, + 3, + 7, + 4, + 5, + 4, + 4, + 2, + 1, + 8, + 6, + 4, + 4, + 3, + 2, + 1, + 1, + 1 + ] + }, + { + "marker": { + "color": "rgb(205, 127, 50)", + "line": { + "color": "rgba(0, 0, 0, 0.5)" + } + }, + "name": "Bronze", + "type": "bar", + "x": [ + "United States of America", + "People's Republic of China", + "Japan", + "Great Britain", + "ROC", + "Australia", + "Netherlands", + "France", + "Germany", + "Italy", + "Canada", + "Brazil", + "New Zealand", + "Cuba", + "Hungary", + "Republic of Korea", + "Poland", + "Czech Republic", + "Kenya", + "Norway", + "Jamaica", + "Spain", + "Sweden", + "Switzerland", + "Denmark", + "Croatia", + "Islamic Republic of Iran", + "Serbia", + "Belgium", + "Bulgaria" + ], + "y": [ + 33, + 18, + 17, + 22, + 23, + 22, + 14, + 11, + 16, + 20, + 11, + 8, + 7, + 5, + 7, + 10, + 5, + 3, + 2, + 2, + 4, + 6, + 0, + 6, + 4, + 2, + 2, + 5, + 3, + 2 + ] + } + ], + "layout": { + "autosize": false, + "barmode": "stack", + "height": 600, + "margin": { + "b": 180, + "l": 30, + "pad": 4, + "r": 30, + "t": 100 + }, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "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": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "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 + }, + "autotypenumbers": "strict", + "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": { + "font": { + "family": "Raleway", + "size": 20 + }, + "text": "Medals earned by participated
Top 20 countries by rank" + }, + "width": 750, + "xaxis": { + "title": { + "text": "Countries" + } + }, + "yaxis": { + "title": { + "text": "Count" + } + } + } + }, + "text/html": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "medals.rename(columns={'Team/NOC':'country'}, inplace=True)\n", + "medals_updated = medals.copy()\n", + "medals_updated['rank'] = medals_updated.index\n", + "medals_updated = medals_updated[medals_updated['rank'] <= 30]\n", + "\n", + "trace1 = go.Bar(\n", + " y=medals_updated.Gold,\n", + " x=medals_updated.country,\n", + " name='Gold',\n", + " marker=dict(\n", + " color='rgb(255,215,0)',\n", + " line=dict(color='rgba(0, 0, 0, 0.5)')\n", + " )\n", + ")\n", + "\n", + "trace2 = go.Bar(\n", + " y=medals_updated.Silver,\n", + " x=medals_updated.country,\n", + " name='Silver',\n", + " marker=dict(\n", + " color='rgb(192,192,192)',\n", + " line=dict(color='rgba(0, 0, 0, 0.5)')\n", + " )\n", + ")\n", + "\n", + "trace3 = go.Bar(\n", + " y=medals_updated.Bronze,\n", + " x=medals_updated.country,\n", + " name='Bronze',\n", + " marker=dict(\n", + " color='rgb(205, 127, 50)',\n", + " line=dict(color='rgba(0, 0, 0, 0.5)')\n", + " )\n", + ")\n", + "\n", + "dt = [trace1, trace2, trace3]\n", + "\n", + "layout = go.Layout(title= 'Medals earned by participated
Top 20 countries by rank',\n", + " title_font=dict(family=\"Raleway\", size=20),\n", + " barmode= 'stack',\n", + " autosize=False,\n", + " width = 750,\n", + " height=600,\n", + " margin=dict(\n", + " l=30,\n", + " r=30,\n", + " b=180,\n", + " t=100,\n", + " pad=4),\n", + " xaxis = {'title':'Countries'},\n", + " yaxis = {'title':'Count'})\n", + "\n", + "fig = go.Figure(data = dt, layout = layout)\n", + "fig.show()" + ] } ], "metadata": {