{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import plotly\n", "import plotly.graph_objs as go\n", "import numpy as np\n", "plotly.offline.init_notebook_mode()\n", "\n", "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Data are from : https://esa.un.org/unpd/wpp/Download/Standard/Population/" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "File WPP2015_DB03_Population_Quinquennial.csv\r", "\r\n", "\r", "\r\n", "Description: Population by five-year age group and by sex, major area, region and country, 1950-2100 (Estimates and No-AIDS estimates and all 8 projection variants) in thousands.\r", "\r\n", "Source: Population Division of the Department of Economic and Social Affairs of the United Nations Secretariat, World Population Prospects: The 2015 Revision, http://esa.un.org/unpd/wpp/index.htm, July 2015.\r", "\r\n", "\r", "\r\n", "Database format with Sex and Age in rows. File size is 271.7MB.\r", "\r\n", "File format is ASCII CSV text file (comma delimited separator with text fields in quotes).\r", "\r\n", "\r", "\r\n", "This data file contains 3,506,016 data records, plus one header record containing the 12 field names as specified below:\r", "\r\n", "\r", "\r\n", "-------------------------------------------------------------------------------\r", "\r\n", "Field name Description\r", "\r\n", "-------------------------------------------------------------------------------\r", "\r\n", "LocID Numerical Location Code (3-digit codes following ISO 3166-1 numeric standard) - see http://en.wikipedia.org/wiki/ISO_3166-1_numeric\r", "\r\n", "Location Name of country, region, major area or other aggregate\r", "\r\n", "VarID Projection variant code\r", "\r\n", " 2=Medium; 3=High; 4=Low; 5=Constant fertility;\r", "\r\n", " 6=Instant-replacement; 7=Zero-migration; 8=Constant-mortality; 9=No change\r", "\r\n", "Variant Projection variant name\r", "\r\n", "Time Calendar year (1 July)\r", "\r\n", "MidPeriod Mid-Period\r", "\r\n", "SexID Sex code (1=Male, 2=Female, 3=Both)\r", "\r\n", "Sex Male, Female, Both\r", "\r\n", "AgeGrp Age group (years)\r", "\r\n", "AgeGrpStart Age group (start, years)\r", "\r\n", "AgeGrpSpan Age group (span, years)\r", "\r\n", "Value population figure (in thousands)\r", "\r\n", "-------------------------------------------------------------------------------\r", "\r\n", "Sorted by: VarID LocID Time SexID AgeGrpStart\r", "\r\n", "\r", "\r\n", "\r", "\r\n", "Sample records (beginning and end of file):\r", "\r\n", "\r", "\r\n", "LocID,Location,VarID,Variant,Time,MidPeriod,SexID,Sex,AgeGrp,AgeGrpStart,AgeGrpSpan,Value\r", "\r\n", "4,\"Afghanistan\",2,\"Medium\",\"1950\",1950.5,1,\"Male\",\"0-4\",0,5,630.044\r", "\r\n", "4,\"Afghanistan\",2,\"Medium\",\"1950\",1950.5,1,\"Male\",\"5-9\",5,5,516.205\r", "\r\n", "4,\"Afghanistan\",2,\"Medium\",\"1950\",1950.5,1,\"Male\",\"10-14\",10,5,461.378\r", "\r\n", "4,\"Afghanistan\",2,\"Medium\",\"1950\",1950.5,1,\"Male\",\"15-19\",15,5,414.368\r", "\r\n", "...\r", "\r\n", "5501,\"Southern Asia\",9,\"No change\",\"2100\",2100.5,3,\"Both\",\"85-89\",85,5,23383.865\r", "\r\n", "5501,\"Southern Asia\",9,\"No change\",\"2100\",2100.5,3,\"Both\",\"90-94\",90,5,9357.079\r", "\r\n", "5501,\"Southern Asia\",9,\"No change\",\"2100\",2100.5,3,\"Both\",\"95-99\",95,5,2677.819\r", "\r\n", "5501,\"Southern Asia\",9,\"No change\",\"2100\",2100.5,3,\"Both\",\"100+\",100,-1,628.437\r", "\r\n" ] } ], "source": [ "cat ../../Downloads/WPP2015_DB03_Population_Quinquennial.txt" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Downloads/WPP2015_DB03_Population_Quinquennial.csv: text/plain; charset=us-ascii\r\n" ] } ], "source": [ "!file -I ../../Downloads/WPP2015_DB03_Population_Quinquennial.csv" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "collapsed": false }, "outputs": [], "source": [ "!iconv -c -f us-ascii -t utf-8 ../../Downloads/WPP2015_DB03_Population_Quinquennial.csv > ../../Downloads/data_utf-8.csv" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "df = pd.read_csv(\"../../Downloads/data_utf-8.csv\")\n", "#df = pd.read_csv(\"Downloads/WPP2015_DB03_Population_Quinquennial.csv\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false, "scrolled": true }, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
LocIDLocationVarIDVariantTimeMidPeriodSexIDSexAgeGrpAgeGrpStartAgeGrpSpanValue
04Afghanistan2Medium19501950.51Male0-405630.044
14Afghanistan2Medium19501950.51Male5-955516.205
24Afghanistan2Medium19501950.51Male10-14105461.378
34Afghanistan2Medium19501950.51Male15-19155414.368
44Afghanistan2Medium19501950.51Male20-24205374.110
54Afghanistan2Medium19501950.51Male25-29255321.312
64Afghanistan2Medium19501950.51Male30-34305276.279
74Afghanistan2Medium19501950.51Male35-39355236.792
84Afghanistan2Medium19501950.51Male40-44405200.616
94Afghanistan2Medium19501950.51Male45-49455176.525
104Afghanistan2Medium19501950.51Male50-54505147.125
114Afghanistan2Medium19501950.51Male55-59555123.896
124Afghanistan2Medium19501950.51Male60-6460594.573
134Afghanistan2Medium19501950.51Male65-6965565.058
144Afghanistan2Medium19501950.51Male70-7470537.982
154Afghanistan2Medium19501950.51Male75-7975517.011
164Afghanistan2Medium19501950.51Male80+80205.967
174Afghanistan2Medium19501950.52Female0-405661.578
184Afghanistan2Medium19501950.52Female5-955487.335
194Afghanistan2Medium19501950.52Female10-14105423.326
204Afghanistan2Medium19501950.52Female15-19155369.364
214Afghanistan2Medium19501950.52Female20-24205318.391
224Afghanistan2Medium19501950.52Female25-29255272.299
234Afghanistan2Medium19501950.52Female30-34305232.168
244Afghanistan2Medium19501950.52Female35-39355197.327
254Afghanistan2Medium19501950.52Female40-44405167.180
264Afghanistan2Medium19501950.52Female45-49455141.220
274Afghanistan2Medium19501950.52Female50-54505117.700
284Afghanistan2Medium19501950.52Female55-5955595.305
294Afghanistan2Medium19501950.52Female60-6460572.748
.......................................
35059865501Southern Asia9No change21002100.52Female60-6460578915.639
35059875501Southern Asia9No change21002100.52Female65-6965568736.724
35059885501Southern Asia9No change21002100.52Female70-7470556055.250
35059895501Southern Asia9No change21002100.52Female75-7975540954.046
35059905501Southern Asia9No change21002100.52Female80-8480525628.437
35059915501Southern Asia9No change21002100.52Female85-8985512766.091
35059925501Southern Asia9No change21002100.52Female90-949055222.857
35059935501Southern Asia9No change21002100.52Female95-999551522.054
35059945501Southern Asia9No change21002100.52Female100+100-1363.748
35059955501Southern Asia9No change21002100.53Both0-405336799.340
35059965501Southern Asia9No change21002100.53Both5-955315867.869
35059975501Southern Asia9No change21002100.53Both10-14105299617.552
35059985501Southern Asia9No change21002100.53Both15-19155284973.163
35059995501Southern Asia9No change21002100.53Both20-24205270571.153
35060005501Southern Asia9No change21002100.53Both25-29255256291.283
35060015501Southern Asia9No change21002100.53Both30-34305242540.335
35060025501Southern Asia9No change21002100.53Both35-39355229835.136
35060035501Southern Asia9No change21002100.53Both40-44405218324.340
35060045501Southern Asia9No change21002100.53Both45-49455206706.644
35060055501Southern Asia9No change21002100.53Both50-54505193000.834
35060065501Southern Asia9No change21002100.53Both55-59555176368.201
35060075501Southern Asia9No change21002100.53Both60-64605157055.766
35060085501Southern Asia9No change21002100.53Both65-69655135282.885
35060095501Southern Asia9No change21002100.53Both70-74705108810.990
35060105501Southern Asia9No change21002100.53Both75-7975578140.567
35060115501Southern Asia9No change21002100.53Both80-8480547941.804
35060125501Southern Asia9No change21002100.53Both85-8985523383.865
35060135501Southern Asia9No change21002100.53Both90-949059357.079
35060145501Southern Asia9No change21002100.53Both95-999552677.819
35060155501Southern Asia9No change21002100.53Both100+100-1628.437
\n", "

3506016 rows × 12 columns

\n", "
" ], "text/plain": [ " LocID Location VarID Variant Time MidPeriod SexID \\\n", "0 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "1 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "2 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "3 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "4 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "5 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "6 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "7 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "8 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "9 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "10 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "11 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "12 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "13 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "14 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "15 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "16 4 Afghanistan 2 Medium 1950 1950.5 1 \n", "17 4 Afghanistan 2 Medium 1950 1950.5 2 \n", "18 4 Afghanistan 2 Medium 1950 1950.5 2 \n", "19 4 Afghanistan 2 Medium 1950 1950.5 2 \n", "20 4 Afghanistan 2 Medium 1950 1950.5 2 \n", "21 4 Afghanistan 2 Medium 1950 1950.5 2 \n", "22 4 Afghanistan 2 Medium 1950 1950.5 2 \n", "23 4 Afghanistan 2 Medium 1950 1950.5 2 \n", "24 4 Afghanistan 2 Medium 1950 1950.5 2 \n", "25 4 Afghanistan 2 Medium 1950 1950.5 2 \n", "26 4 Afghanistan 2 Medium 1950 1950.5 2 \n", "27 4 Afghanistan 2 Medium 1950 1950.5 2 \n", "28 4 Afghanistan 2 Medium 1950 1950.5 2 \n", "29 4 Afghanistan 2 Medium 1950 1950.5 2 \n", "... ... ... ... ... ... ... ... \n", "3505986 5501 Southern Asia 9 No change 2100 2100.5 2 \n", "3505987 5501 Southern Asia 9 No change 2100 2100.5 2 \n", "3505988 5501 Southern Asia 9 No change 2100 2100.5 2 \n", "3505989 5501 Southern Asia 9 No change 2100 2100.5 2 \n", "3505990 5501 Southern Asia 9 No change 2100 2100.5 2 \n", "3505991 5501 Southern Asia 9 No change 2100 2100.5 2 \n", "3505992 5501 Southern Asia 9 No change 2100 2100.5 2 \n", "3505993 5501 Southern Asia 9 No change 2100 2100.5 2 \n", "3505994 5501 Southern Asia 9 No change 2100 2100.5 2 \n", "3505995 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3505996 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3505997 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3505998 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3505999 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506000 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506001 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506002 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506003 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506004 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506005 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506006 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506007 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506008 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506009 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506010 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506011 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506012 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506013 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506014 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "3506015 5501 Southern Asia 9 No change 2100 2100.5 3 \n", "\n", " Sex AgeGrp AgeGrpStart AgeGrpSpan Value \n", "0 Male 0-4 0 5 630.044 \n", "1 Male 5-9 5 5 516.205 \n", "2 Male 10-14 10 5 461.378 \n", "3 Male 15-19 15 5 414.368 \n", "4 Male 20-24 20 5 374.110 \n", "5 Male 25-29 25 5 321.312 \n", "6 Male 30-34 30 5 276.279 \n", "7 Male 35-39 35 5 236.792 \n", "8 Male 40-44 40 5 200.616 \n", "9 Male 45-49 45 5 176.525 \n", "10 Male 50-54 50 5 147.125 \n", "11 Male 55-59 55 5 123.896 \n", "12 Male 60-64 60 5 94.573 \n", "13 Male 65-69 65 5 65.058 \n", "14 Male 70-74 70 5 37.982 \n", "15 Male 75-79 75 5 17.011 \n", "16 Male 80+ 80 20 5.967 \n", "17 Female 0-4 0 5 661.578 \n", "18 Female 5-9 5 5 487.335 \n", "19 Female 10-14 10 5 423.326 \n", "20 Female 15-19 15 5 369.364 \n", "21 Female 20-24 20 5 318.391 \n", "22 Female 25-29 25 5 272.299 \n", "23 Female 30-34 30 5 232.168 \n", "24 Female 35-39 35 5 197.327 \n", "25 Female 40-44 40 5 167.180 \n", "26 Female 45-49 45 5 141.220 \n", "27 Female 50-54 50 5 117.700 \n", "28 Female 55-59 55 5 95.305 \n", "29 Female 60-64 60 5 72.748 \n", "... ... ... ... ... ... \n", "3505986 Female 60-64 60 5 78915.639 \n", "3505987 Female 65-69 65 5 68736.724 \n", "3505988 Female 70-74 70 5 56055.250 \n", "3505989 Female 75-79 75 5 40954.046 \n", "3505990 Female 80-84 80 5 25628.437 \n", "3505991 Female 85-89 85 5 12766.091 \n", "3505992 Female 90-94 90 5 5222.857 \n", "3505993 Female 95-99 95 5 1522.054 \n", "3505994 Female 100+ 100 -1 363.748 \n", "3505995 Both 0-4 0 5 336799.340 \n", "3505996 Both 5-9 5 5 315867.869 \n", "3505997 Both 10-14 10 5 299617.552 \n", "3505998 Both 15-19 15 5 284973.163 \n", "3505999 Both 20-24 20 5 270571.153 \n", "3506000 Both 25-29 25 5 256291.283 \n", "3506001 Both 30-34 30 5 242540.335 \n", "3506002 Both 35-39 35 5 229835.136 \n", "3506003 Both 40-44 40 5 218324.340 \n", "3506004 Both 45-49 45 5 206706.644 \n", "3506005 Both 50-54 50 5 193000.834 \n", "3506006 Both 55-59 55 5 176368.201 \n", "3506007 Both 60-64 60 5 157055.766 \n", "3506008 Both 65-69 65 5 135282.885 \n", "3506009 Both 70-74 70 5 108810.990 \n", "3506010 Both 75-79 75 5 78140.567 \n", "3506011 Both 80-84 80 5 47941.804 \n", "3506012 Both 85-89 85 5 23383.865 \n", "3506013 Both 90-94 90 5 9357.079 \n", "3506014 Both 95-99 95 5 2677.819 \n", "3506015 Both 100+ 100 -1 628.437 \n", "\n", "[3506016 rows x 12 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First we do the following selection :\n", "\n", "* 2015 data\n", "* \"Variant\" = \"Medium\"\n", "* Sex : male + female\n", "* LocID (ISO-3) > 900 (only continent)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false, "scrolled": true }, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
LocIDLocationVarIDVariantTimeMidPeriodSexIDSexAgeGrpAgeGrpStartAgeGrpSpanValue
86187203Czech Republic2Medium20152015.53Both0-405537.906
86188203Czech Republic2Medium20152015.53Both5-955568.736
86189203Czech Republic2Medium20152015.53Both10-14105479.253
86190203Czech Republic2Medium20152015.53Both15-19155452.632
86191203Czech Republic2Medium20152015.53Both20-24205608.909
86192203Czech Republic2Medium20152015.53Both25-29255694.583
86193203Czech Republic2Medium20152015.53Both30-34305745.225
86194203Czech Republic2Medium20152015.53Both35-39355921.292
86195203Czech Republic2Medium20152015.53Both40-44405866.557
86196203Czech Republic2Medium20152015.53Both45-49455698.852
86197203Czech Republic2Medium20152015.53Both50-54505670.235
86198203Czech Republic2Medium20152015.53Both55-59555668.736
86199203Czech Republic2Medium20152015.53Both60-64605724.485
86200203Czech Republic2Medium20152015.53Both65-69655678.067
86201203Czech Republic2Medium20152015.53Both70-74705490.259
86202203Czech Republic2Medium20152015.53Both75-79755308.944
86203203Czech Republic2Medium20152015.53Both80-84805236.592
86204203Czech Republic2Medium20152015.53Both85-89855133.771
86205203Czech Republic2Medium20152015.53Both90-9490552.106
86206203Czech Republic2Medium20152015.53Both95-999555.207
86207203Czech Republic2Medium20152015.53Both100+100-10.839
88044204Benin2Medium20152015.53Both0-4051707.733
88045204Benin2Medium20152015.53Both5-9551523.648
88046204Benin2Medium20152015.53Both10-141051355.381
88047204Benin2Medium20152015.53Both15-191551172.421
88048204Benin2Medium20152015.53Both20-242051001.630
88049204Benin2Medium20152015.53Both25-29255843.297
88050204Benin2Medium20152015.53Both30-34305709.637
88051204Benin2Medium20152015.53Both35-39355592.432
88052204Benin2Medium20152015.53Both40-44405492.745
.......................................
106626246Finland2Medium20152015.53Both60-64605368.737
106627246Finland2Medium20152015.53Both65-69655407.749
106628246Finland2Medium20152015.53Both70-74705239.669
106629246Finland2Medium20152015.53Both75-79755196.876
106630246Finland2Medium20152015.53Both80-84805146.452
106631246Finland2Medium20152015.53Both85-8985592.263
106632246Finland2Medium20152015.53Both90-9490536.385
106633246Finland2Medium20152015.53Both95-999556.825
106634246Finland2Medium20152015.53Both100+100-10.734
108471250France2Medium20152015.53Both0-4053926.920
108472250France2Medium20152015.53Both5-9553986.544
108473250France2Medium20152015.53Both10-141053989.071
108474250France2Medium20152015.53Both15-191553802.700
108475250France2Medium20152015.53Both20-242053652.962
108476250France2Medium20152015.53Both25-292553902.296
108477250France2Medium20152015.53Both30-343053992.084
108478250France2Medium20152015.53Both35-393553872.985
108479250France2Medium20152015.53Both40-444054335.701
108480250France2Medium20152015.53Both45-494554301.844
108481250France2Medium20152015.53Both50-545054308.345
108482250France2Medium20152015.53Both55-595554074.735
108483250France2Medium20152015.53Both60-646053936.439
108484250France2Medium20152015.53Both65-696553791.252
108485250France2Medium20152015.53Both70-747052431.887
108486250France2Medium20152015.53Both75-797552193.359
108487250France2Medium20152015.53Both80-848051892.085
108488250France2Medium20152015.53Both85-898551251.442
108489250France2Medium20152015.53Both90-94905638.155
108490250France2Medium20152015.53Both95-9995594.771
108491250France2Medium20152015.53Both100+100-119.768
\n", "

273 rows × 12 columns

\n", "
" ], "text/plain": [ " LocID Location VarID Variant Time MidPeriod SexID Sex \\\n", "86187 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86188 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86189 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86190 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86191 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86192 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86193 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86194 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86195 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86196 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86197 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86198 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86199 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86200 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86201 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86202 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86203 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86204 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86205 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86206 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "86207 203 Czech Republic 2 Medium 2015 2015.5 3 Both \n", "88044 204 Benin 2 Medium 2015 2015.5 3 Both \n", "88045 204 Benin 2 Medium 2015 2015.5 3 Both \n", "88046 204 Benin 2 Medium 2015 2015.5 3 Both \n", "88047 204 Benin 2 Medium 2015 2015.5 3 Both \n", "88048 204 Benin 2 Medium 2015 2015.5 3 Both \n", "88049 204 Benin 2 Medium 2015 2015.5 3 Both \n", "88050 204 Benin 2 Medium 2015 2015.5 3 Both \n", "88051 204 Benin 2 Medium 2015 2015.5 3 Both \n", "88052 204 Benin 2 Medium 2015 2015.5 3 Both \n", "... ... ... ... ... ... ... ... ... \n", "106626 246 Finland 2 Medium 2015 2015.5 3 Both \n", "106627 246 Finland 2 Medium 2015 2015.5 3 Both \n", "106628 246 Finland 2 Medium 2015 2015.5 3 Both \n", "106629 246 Finland 2 Medium 2015 2015.5 3 Both \n", "106630 246 Finland 2 Medium 2015 2015.5 3 Both \n", "106631 246 Finland 2 Medium 2015 2015.5 3 Both \n", "106632 246 Finland 2 Medium 2015 2015.5 3 Both \n", "106633 246 Finland 2 Medium 2015 2015.5 3 Both \n", "106634 246 Finland 2 Medium 2015 2015.5 3 Both \n", "108471 250 France 2 Medium 2015 2015.5 3 Both \n", "108472 250 France 2 Medium 2015 2015.5 3 Both \n", "108473 250 France 2 Medium 2015 2015.5 3 Both \n", "108474 250 France 2 Medium 2015 2015.5 3 Both \n", "108475 250 France 2 Medium 2015 2015.5 3 Both \n", "108476 250 France 2 Medium 2015 2015.5 3 Both \n", "108477 250 France 2 Medium 2015 2015.5 3 Both \n", "108478 250 France 2 Medium 2015 2015.5 3 Both \n", "108479 250 France 2 Medium 2015 2015.5 3 Both \n", "108480 250 France 2 Medium 2015 2015.5 3 Both \n", "108481 250 France 2 Medium 2015 2015.5 3 Both \n", "108482 250 France 2 Medium 2015 2015.5 3 Both \n", "108483 250 France 2 Medium 2015 2015.5 3 Both \n", "108484 250 France 2 Medium 2015 2015.5 3 Both \n", "108485 250 France 2 Medium 2015 2015.5 3 Both \n", "108486 250 France 2 Medium 2015 2015.5 3 Both \n", "108487 250 France 2 Medium 2015 2015.5 3 Both \n", "108488 250 France 2 Medium 2015 2015.5 3 Both \n", "108489 250 France 2 Medium 2015 2015.5 3 Both \n", "108490 250 France 2 Medium 2015 2015.5 3 Both \n", "108491 250 France 2 Medium 2015 2015.5 3 Both \n", "\n", " AgeGrp AgeGrpStart AgeGrpSpan Value \n", "86187 0-4 0 5 537.906 \n", "86188 5-9 5 5 568.736 \n", "86189 10-14 10 5 479.253 \n", "86190 15-19 15 5 452.632 \n", "86191 20-24 20 5 608.909 \n", "86192 25-29 25 5 694.583 \n", "86193 30-34 30 5 745.225 \n", "86194 35-39 35 5 921.292 \n", "86195 40-44 40 5 866.557 \n", "86196 45-49 45 5 698.852 \n", "86197 50-54 50 5 670.235 \n", "86198 55-59 55 5 668.736 \n", "86199 60-64 60 5 724.485 \n", "86200 65-69 65 5 678.067 \n", "86201 70-74 70 5 490.259 \n", "86202 75-79 75 5 308.944 \n", "86203 80-84 80 5 236.592 \n", "86204 85-89 85 5 133.771 \n", "86205 90-94 90 5 52.106 \n", "86206 95-99 95 5 5.207 \n", "86207 100+ 100 -1 0.839 \n", "88044 0-4 0 5 1707.733 \n", "88045 5-9 5 5 1523.648 \n", "88046 10-14 10 5 1355.381 \n", "88047 15-19 15 5 1172.421 \n", "88048 20-24 20 5 1001.630 \n", "88049 25-29 25 5 843.297 \n", "88050 30-34 30 5 709.637 \n", "88051 35-39 35 5 592.432 \n", "88052 40-44 40 5 492.745 \n", "... ... ... ... ... \n", "106626 60-64 60 5 368.737 \n", "106627 65-69 65 5 407.749 \n", "106628 70-74 70 5 239.669 \n", "106629 75-79 75 5 196.876 \n", "106630 80-84 80 5 146.452 \n", "106631 85-89 85 5 92.263 \n", "106632 90-94 90 5 36.385 \n", "106633 95-99 95 5 6.825 \n", "106634 100+ 100 -1 0.734 \n", "108471 0-4 0 5 3926.920 \n", "108472 5-9 5 5 3986.544 \n", "108473 10-14 10 5 3989.071 \n", "108474 15-19 15 5 3802.700 \n", "108475 20-24 20 5 3652.962 \n", "108476 25-29 25 5 3902.296 \n", "108477 30-34 30 5 3992.084 \n", "108478 35-39 35 5 3872.985 \n", "108479 40-44 40 5 4335.701 \n", "108480 45-49 45 5 4301.844 \n", "108481 50-54 50 5 4308.345 \n", "108482 55-59 55 5 4074.735 \n", "108483 60-64 60 5 3936.439 \n", "108484 65-69 65 5 3791.252 \n", "108485 70-74 70 5 2431.887 \n", "108486 75-79 75 5 2193.359 \n", "108487 80-84 80 5 1892.085 \n", "108488 85-89 85 5 1251.442 \n", "108489 90-94 90 5 638.155 \n", "108490 95-99 95 5 94.771 \n", "108491 100+ 100 -1 19.768 \n", "\n", "[273 rows x 12 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df2015 = df[(df[\"Time\"] == 2015) & (df[\"Sex\"] == \"Both\") & (df[\"Variant\"] == \"Medium\") & (200 < df[\"LocID\"]) & (df[\"LocID\"] <= 250)]\n", "df2015" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false, "scrolled": true }, "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", "
LocIDTimeSexVariantValue
Location
Benin2042015BothMedium10879.829
Czech Republic2032015BothMedium10543.186
Denmark2082015BothMedium5669.081
Dominican Republic2142015BothMedium10528.391
Ecuador2182015BothMedium16144.363
El Salvador2222015BothMedium6126.583
Equatorial Guinea2262015BothMedium845.060
Eritrea2322015BothMedium5227.791
Estonia2332015BothMedium1312.558
Ethiopia2312015BothMedium99390.750
Fiji2422015BothMedium892.145
Finland2462015BothMedium5503.457
France2502015BothMedium64395.345
\n", "
" ], "text/plain": [ " LocID Time Sex Variant Value\n", "Location \n", "Benin 204 2015 Both Medium 10879.829\n", "Czech Republic 203 2015 Both Medium 10543.186\n", "Denmark 208 2015 Both Medium 5669.081\n", "Dominican Republic 214 2015 Both Medium 10528.391\n", "Ecuador 218 2015 Both Medium 16144.363\n", "El Salvador 222 2015 Both Medium 6126.583\n", "Equatorial Guinea 226 2015 Both Medium 845.060\n", "Eritrea 232 2015 Both Medium 5227.791\n", "Estonia 233 2015 Both Medium 1312.558\n", "Ethiopia 231 2015 Both Medium 99390.750\n", "Fiji 242 2015 Both Medium 892.145\n", "Finland 246 2015 Both Medium 5503.457\n", "France 250 2015 Both Medium 64395.345" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df2015 = df2015.groupby([\"Location\", \"LocID\", \"Time\", \"Sex\", \"Variant\"], as_index=False).aggregate({\"Value\": np.sum})\n", "df2015 = df2015.set_index(\"Location\")\n", "df2015" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "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", "
LocIDTimeSexVariantValue
Location
AFRICA9032015BothMedium1186178.282
ASIA9352015BothMedium4393296.014
EUROPE9082015BothMedium738442.070
NORTHERN AMERICA9052015BothMedium357838.036
OCEANIA9092015BothMedium39331.130
\n", "
" ], "text/plain": [ " LocID Time Sex Variant Value\n", "Location \n", "AFRICA 903 2015 Both Medium 1186178.282\n", "ASIA 935 2015 Both Medium 4393296.014\n", "EUROPE 908 2015 Both Medium 738442.070\n", "NORTHERN AMERICA 905 2015 Both Medium 357838.036\n", "OCEANIA 909 2015 Both Medium 39331.130" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_continent = df2015.loc[[\"AFRICA\", \"ASIA\", \"EUROPE\", \"NORTHERN AMERICA\", \"OCEANIA\"]]\n", "df_continent" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false, "scrolled": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "colorscale = [[0.0, 'rgb(242,240,247)'],[0.2, 'rgb(218,218,235)'],[0.4, 'rgb(188,189,220)'],\n", " [0.6, 'rgb(158,154,200)'],[0.8, 'rgb(117,107,177)'],[1.0, 'rgb(84,39,143)']]\n", "data = [\n", " dict(\n", " type='choropleth',\n", " colorscale = colorscale,\n", " autocolorscale = False,\n", " locations = df2015.index,\n", " z = df2015['Value'],\n", " locationmode = 'country name',\n", " text = df2015.index.astype(str) + \" \" + str(df2015[\"Value\"]),\n", " marker = dict(\n", " line = dict (\n", " color = 'rgb(255,255,255)',\n", " width = 2\n", " ) ),\n", " colorbar = dict(\n", " title = \"Population\")\n", " ) ]\n", "\n", "layout = dict(\n", " title = 'World population by countries',\n", " geo = dict(\n", " scope='world',\n", " projection=dict( type='natural earth' )\n", " )\n", " )\n", " \n", "fig = dict( data=data, layout=layout )\n", "plotly.plotly.iplot( fig, filename='world-map' )\n", "#plotly.plotly.image.save_as(fig, \"d3-map.png\")" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": false, "scrolled": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "colorscale = [[0.0, 'rgb(242,240,247)'],[0.2, 'rgb(218,218,235)'],[0.4, 'rgb(188,189,220)'],\n", " [0.6, 'rgb(158,154,200)'],[0.8, 'rgb(117,107,177)'],[1.0, 'rgb(84,39,143)']]\n", "data = [\n", " dict(\n", " type='choropleth',\n", " colorscale = colorscale,\n", " autocolorscale = False,\n", " locations = df_continent[\"LocID\"],\n", " z = df_continent['Value'],\n", " locationmode = 'country name',\n", " text = df_continent.index.astype(str) + \" \" + str(df_continent[\"Value\"]),\n", " marker = dict(\n", " line = dict (\n", " color = 'rgb(255,255,255)',\n", " width = 2\n", " ) ),\n", " colorbar = dict(\n", " title = \"Population\")\n", " ) ]\n", "\n", "layout = dict(\n", " title = 'World population by countries',\n", " geo = dict(\n", " scope='world',\n", " projection=dict( type='orthographic' )\n", " )\n", " )\n", " \n", "fig = dict( data=data, layout=layout )\n", "plotly.plotly.iplot( fig, filename='world-map' )\n", "#plotly.plotly.image.save_as(fig, \"d3-map.png\")" ] } ], "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.5.1" } }, "nbformat": 4, "nbformat_minor": 0 }