{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exploring data on COVID-19\n",
"\n",
"> In this post, We will cover the basic syntax of julia language, and explore the data related on COVID-19. This is the summary of lecture \"Introduction to Computational Thinking with Julia, with applications to modeling the COVID-19 Pandemic\" from MIT.\n",
"\n",
"- toc: true \n",
"- badges: true\n",
"- comments: true\n",
"- author: Chanseok Kang\n",
"- categories: [Julia, MIT]\n",
"- image: images/US_data.png"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Why Julia?\n",
"\n",
"- Julia: Developed at MIT by Prof. Alan Edelman's group\n",
"- Released in 2012.\n",
"- Current release: 1.4\n",
"\n",
"- Free, open source software\n",
"- developed by world-wide community on [Github](https://github.com/JuliaLang/julia)\n",
"- Over 3000 registered packages in wide range of domains\n",
"\n",
"## Julia\n",
"\n",
"- Modern, powerful language\n",
"- Interactive but high performance (fast) - previously mutually exclusive\n",
"- Syntax: similar to Python / Matlab / R\n",
"- But carefully designed for high-performance computational science & engineering applications\n",
"- Design means that most of Julia is written in Julia itself\n",
"- Hence much easier to examine and modify algorithms"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![us_data](image/US_data.png)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv\""
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"url = \"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv\""
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv\""
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"url"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"String"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"typeof(url)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"* (generic function with 357 methods)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"*"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1 + 7im"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(1 + 2im) * (3 + im)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"*(z::Complex , w::Complex ) in Base at complex.jl:277 "
],
"text/plain": [
"*(z::Complex, w::Complex) in Base at complex.jl:277"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"@which (1+ 2im) * (3 + im)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Grab the data"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"covid_data.csv\""
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"download(url, \"covid_data.csv\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"readdir (generic function with 2 methods)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"readdir"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"234-element Array{String,1}:\n",
" \".ipynb_checkpoints\"\n",
" \"2020-05-21-Software-Engineering-Practices-Pt-1.ipynb\"\n",
" \"2020-05-22-01-Decorator.ipynb\"\n",
" \"2020-05-22-02-More-On-Decorators.ipynb\"\n",
" \"2020-05-23-01-Read-clean-and-validate.ipynb\"\n",
" \"2020-05-23-02-Distributions.ipynb\"\n",
" \"2020-05-24-01-Relationships.ipynb\"\n",
" \"2020-05-24-02-Multivariate-Thinking.ipynb\"\n",
" \"2020-05-25-01-Preparing-the-data-for-analysis.ipynb\"\n",
" \"2020-05-25-02-Exploring-the-relationship-between-gender-and-policing.ipynb\"\n",
" \"2020-05-25-03-Visual-exploratory-data-analysis.ipynb\"\n",
" \"2020-05-25-04-Software-Engineering-Practices-Pt-2.ipynb\"\n",
" \"2020-05-26-01-Analyzing-the-effect-of-weather-on-policing.ipynb\"\n",
" ⋮\n",
" \"2020-12-28-01-Exploring-data-on-COVID-19.ipynb\"\n",
" \"README.md\"\n",
" \"checkpoints\"\n",
" \"covid_data.csv\"\n",
" \"dataset\"\n",
" \"html\"\n",
" \"image\"\n",
" \"models\"\n",
" \"my_icons\"\n",
" \"spark-warehouse\"\n",
" \"utils\"\n",
" \"video\""
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"readdir()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Install Package"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m registry at `C:\\Users\\kcsgo\\.julia\\registries\\General`\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[?25l"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m git-repo `https://github.com/JuliaRegistries/General.git`\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[2K\u001b[?25h"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m\u001b[1m Resolving\u001b[22m\u001b[39m package versions...\n",
"\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `C:\\Users\\kcsgo\\.julia\\environments\\v1.4\\Project.toml`\n",
"\u001b[90m [no changes]\u001b[39m\n",
"\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `C:\\Users\\kcsgo\\.julia\\environments\\v1.4\\Manifest.toml`\n",
"\u001b[90m [no changes]\u001b[39m\n"
]
}
],
"source": [
"using Pkg # built-in package manager in Julia: Pkg\n",
"Pkg.add(\"CSV\") # calls the `add` function from the module Pkg. This installs a package"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m\u001b[1m Resolving\u001b[22m\u001b[39m package versions...\n",
"\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `C:\\Users\\kcsgo\\.julia\\environments\\v1.4\\Project.toml`\n",
"\u001b[90m [no changes]\u001b[39m\n",
"\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `C:\\Users\\kcsgo\\.julia\\environments\\v1.4\\Manifest.toml`\n",
"\u001b[90m [no changes]\u001b[39m\n"
]
}
],
"source": [
"Pkg.add(\"DataFrames\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load a package\n",
"\n",
"Load a package every time we run a Julia session:"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"using CSV, DataFrames"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
Province/State Country/Region Lat Long 1/22/20 String? String Float64? Float64? Int64 271 rows × 347 columns (omitted printing of 342 columns)
1 missing Afghanistan 33.9391 67.71 0 2 missing Albania 41.1533 20.1683 0 3 missing Algeria 28.0339 1.6596 0 4 missing Andorra 42.5063 1.5218 0 5 missing Angola -11.2027 17.8739 0 6 missing Antigua and Barbuda 17.0608 -61.7964 0 7 missing Argentina -38.4161 -63.6167 0 8 missing Armenia 40.0691 45.0382 0 9 Australian Capital Territory Australia -35.4735 149.012 0 10 New South Wales Australia -33.8688 151.209 0 11 Northern Territory Australia -12.4634 130.846 0 12 Queensland Australia -27.4698 153.025 0 13 South Australia Australia -34.9285 138.601 0 14 Tasmania Australia -42.8821 147.327 0 15 Victoria Australia -37.8136 144.963 0 16 Western Australia Australia -31.9505 115.861 0 17 missing Austria 47.5162 14.5501 0 18 missing Azerbaijan 40.1431 47.5769 0 19 missing Bahamas 25.0259 -78.0359 0 20 missing Bahrain 26.0275 50.55 0 21 missing Bangladesh 23.685 90.3563 0 22 missing Barbados 13.1939 -59.5432 0 23 missing Belarus 53.7098 27.9534 0 24 missing Belgium 50.8333 4.46994 0 25 missing Belize 17.1899 -88.4976 0 26 missing Benin 9.3077 2.3158 0 27 missing Bhutan 27.5142 90.4336 0 28 missing Bolivia -16.2902 -63.5887 0 29 missing Bosnia and Herzegovina 43.9159 17.6791 0 30 missing Botswana -22.3285 24.6849 0 ⋮ ⋮ ⋮ ⋮ ⋮ ⋮
"
],
"text/latex": [
"\\begin{tabular}{r|cccccc}\n",
"\t& Province/State & Country/Region & Lat & Long & 1/22/20 & \\\\\n",
"\t\\hline\n",
"\t& String? & String & Float64? & Float64? & Int64 & \\\\\n",
"\t\\hline\n",
"\t1 & \\emph{missing} & Afghanistan & 33.9391 & 67.71 & 0 & $\\dots$ \\\\\n",
"\t2 & \\emph{missing} & Albania & 41.1533 & 20.1683 & 0 & $\\dots$ \\\\\n",
"\t3 & \\emph{missing} & Algeria & 28.0339 & 1.6596 & 0 & $\\dots$ \\\\\n",
"\t4 & \\emph{missing} & Andorra & 42.5063 & 1.5218 & 0 & $\\dots$ \\\\\n",
"\t5 & \\emph{missing} & Angola & -11.2027 & 17.8739 & 0 & $\\dots$ \\\\\n",
"\t6 & \\emph{missing} & Antigua and Barbuda & 17.0608 & -61.7964 & 0 & $\\dots$ \\\\\n",
"\t7 & \\emph{missing} & Argentina & -38.4161 & -63.6167 & 0 & $\\dots$ \\\\\n",
"\t8 & \\emph{missing} & Armenia & 40.0691 & 45.0382 & 0 & $\\dots$ \\\\\n",
"\t9 & Australian Capital Territory & Australia & -35.4735 & 149.012 & 0 & $\\dots$ \\\\\n",
"\t10 & New South Wales & Australia & -33.8688 & 151.209 & 0 & $\\dots$ \\\\\n",
"\t11 & Northern Territory & Australia & -12.4634 & 130.846 & 0 & $\\dots$ \\\\\n",
"\t12 & Queensland & Australia & -27.4698 & 153.025 & 0 & $\\dots$ \\\\\n",
"\t13 & South Australia & Australia & -34.9285 & 138.601 & 0 & $\\dots$ \\\\\n",
"\t14 & Tasmania & Australia & -42.8821 & 147.327 & 0 & $\\dots$ \\\\\n",
"\t15 & Victoria & Australia & -37.8136 & 144.963 & 0 & $\\dots$ \\\\\n",
"\t16 & Western Australia & Australia & -31.9505 & 115.861 & 0 & $\\dots$ \\\\\n",
"\t17 & \\emph{missing} & Austria & 47.5162 & 14.5501 & 0 & $\\dots$ \\\\\n",
"\t18 & \\emph{missing} & Azerbaijan & 40.1431 & 47.5769 & 0 & $\\dots$ \\\\\n",
"\t19 & \\emph{missing} & Bahamas & 25.0259 & -78.0359 & 0 & $\\dots$ \\\\\n",
"\t20 & \\emph{missing} & Bahrain & 26.0275 & 50.55 & 0 & $\\dots$ \\\\\n",
"\t21 & \\emph{missing} & Bangladesh & 23.685 & 90.3563 & 0 & $\\dots$ \\\\\n",
"\t22 & \\emph{missing} & Barbados & 13.1939 & -59.5432 & 0 & $\\dots$ \\\\\n",
"\t23 & \\emph{missing} & Belarus & 53.7098 & 27.9534 & 0 & $\\dots$ \\\\\n",
"\t24 & \\emph{missing} & Belgium & 50.8333 & 4.46994 & 0 & $\\dots$ \\\\\n",
"\t25 & \\emph{missing} & Belize & 17.1899 & -88.4976 & 0 & $\\dots$ \\\\\n",
"\t26 & \\emph{missing} & Benin & 9.3077 & 2.3158 & 0 & $\\dots$ \\\\\n",
"\t27 & \\emph{missing} & Bhutan & 27.5142 & 90.4336 & 0 & $\\dots$ \\\\\n",
"\t28 & \\emph{missing} & Bolivia & -16.2902 & -63.5887 & 0 & $\\dots$ \\\\\n",
"\t29 & \\emph{missing} & Bosnia and Herzegovina & 43.9159 & 17.6791 & 0 & $\\dots$ \\\\\n",
"\t30 & \\emph{missing} & Botswana & -22.3285 & 24.6849 & 0 & $\\dots$ \\\\\n",
"\t$\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"\u001b[1m271×347 DataFrame\u001b[0m\n",
"\u001b[1m Row \u001b[0m│\u001b[1m Province/State \u001b[0m\u001b[1m Country/Region \u001b[0m\u001b[1m Lat \u001b[0m\u001b[1m Long \u001b[0m\u001b[1m \u001b[0m ⋯\n",
"\u001b[1m \u001b[0m│\u001b[90m String? \u001b[0m\u001b[90m String \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m \u001b[0m ⋯\n",
"─────┼──────────────────────────────────────────────────────────────────────────\n",
" 1 │\u001b[90m missing \u001b[0m Afghanistan 33.9391 67.71 ⋯\n",
" 2 │\u001b[90m missing \u001b[0m Albania 41.1533 20.1683\n",
" 3 │\u001b[90m missing \u001b[0m Algeria 28.0339 1.6596\n",
" 4 │\u001b[90m missing \u001b[0m Andorra 42.5063 1.5218\n",
" 5 │\u001b[90m missing \u001b[0m Angola -11.2027 17.8739 ⋯\n",
" 6 │\u001b[90m missing \u001b[0m Antigua and Barbuda 17.0608 -61.7964\n",
" 7 │\u001b[90m missing \u001b[0m Argentina -38.4161 -63.6167\n",
" 8 │\u001b[90m missing \u001b[0m Armenia 40.0691 45.0382\n",
" 9 │ Australian Capital Territory Australia -35.4735 149.012 ⋯\n",
" 10 │ New South Wales Australia -33.8688 151.209\n",
" 11 │ Northern Territory Australia -12.4634 130.846\n",
" ⋮ │ ⋮ ⋮ ⋮ ⋮ ⋱\n",
" 262 │\u001b[90m missing \u001b[0m United Kingdom 55.3781 -3.436\n",
" 263 │\u001b[90m missing \u001b[0m Uruguay -32.5228 -55.7658 ⋯\n",
" 264 │\u001b[90m missing \u001b[0m Uzbekistan 41.3775 64.5853\n",
" 265 │\u001b[90m missing \u001b[0m Vanuatu -15.3767 166.959\n",
" 266 │\u001b[90m missing \u001b[0m Venezuela 6.4238 -66.5897\n",
" 267 │\u001b[90m missing \u001b[0m Vietnam 14.0583 108.277 ⋯\n",
" 268 │\u001b[90m missing \u001b[0m West Bank and Gaza 31.9522 35.2332\n",
" 269 │\u001b[90m missing \u001b[0m Yemen 15.5527 48.5164\n",
" 270 │\u001b[90m missing \u001b[0m Zambia -13.1339 27.8493\n",
" 271 │\u001b[90m missing \u001b[0m Zimbabwe -19.0154 29.1549 ⋯\n",
"\u001b[31m 343 columns and 250 rows omitted\u001b[0m"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"CSV.read(\"./covid_data.csv\", DataFrame)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"Province/State Country/Region Lat Long 1/22/20 String? String Float64? Float64? Int64 271 rows × 347 columns (omitted printing of 342 columns)
1 missing Afghanistan 33.9391 67.71 0 2 missing Albania 41.1533 20.1683 0 3 missing Algeria 28.0339 1.6596 0 4 missing Andorra 42.5063 1.5218 0 5 missing Angola -11.2027 17.8739 0 6 missing Antigua and Barbuda 17.0608 -61.7964 0 7 missing Argentina -38.4161 -63.6167 0 8 missing Armenia 40.0691 45.0382 0 9 Australian Capital Territory Australia -35.4735 149.012 0 10 New South Wales Australia -33.8688 151.209 0 11 Northern Territory Australia -12.4634 130.846 0 12 Queensland Australia -27.4698 153.025 0 13 South Australia Australia -34.9285 138.601 0 14 Tasmania Australia -42.8821 147.327 0 15 Victoria Australia -37.8136 144.963 0 16 Western Australia Australia -31.9505 115.861 0 17 missing Austria 47.5162 14.5501 0 18 missing Azerbaijan 40.1431 47.5769 0 19 missing Bahamas 25.0259 -78.0359 0 20 missing Bahrain 26.0275 50.55 0 21 missing Bangladesh 23.685 90.3563 0 22 missing Barbados 13.1939 -59.5432 0 23 missing Belarus 53.7098 27.9534 0 24 missing Belgium 50.8333 4.46994 0 25 missing Belize 17.1899 -88.4976 0 26 missing Benin 9.3077 2.3158 0 27 missing Bhutan 27.5142 90.4336 0 28 missing Bolivia -16.2902 -63.5887 0 29 missing Bosnia and Herzegovina 43.9159 17.6791 0 30 missing Botswana -22.3285 24.6849 0 ⋮ ⋮ ⋮ ⋮ ⋮ ⋮
"
],
"text/latex": [
"\\begin{tabular}{r|cccccc}\n",
"\t& Province/State & Country/Region & Lat & Long & 1/22/20 & \\\\\n",
"\t\\hline\n",
"\t& String? & String & Float64? & Float64? & Int64 & \\\\\n",
"\t\\hline\n",
"\t1 & \\emph{missing} & Afghanistan & 33.9391 & 67.71 & 0 & $\\dots$ \\\\\n",
"\t2 & \\emph{missing} & Albania & 41.1533 & 20.1683 & 0 & $\\dots$ \\\\\n",
"\t3 & \\emph{missing} & Algeria & 28.0339 & 1.6596 & 0 & $\\dots$ \\\\\n",
"\t4 & \\emph{missing} & Andorra & 42.5063 & 1.5218 & 0 & $\\dots$ \\\\\n",
"\t5 & \\emph{missing} & Angola & -11.2027 & 17.8739 & 0 & $\\dots$ \\\\\n",
"\t6 & \\emph{missing} & Antigua and Barbuda & 17.0608 & -61.7964 & 0 & $\\dots$ \\\\\n",
"\t7 & \\emph{missing} & Argentina & -38.4161 & -63.6167 & 0 & $\\dots$ \\\\\n",
"\t8 & \\emph{missing} & Armenia & 40.0691 & 45.0382 & 0 & $\\dots$ \\\\\n",
"\t9 & Australian Capital Territory & Australia & -35.4735 & 149.012 & 0 & $\\dots$ \\\\\n",
"\t10 & New South Wales & Australia & -33.8688 & 151.209 & 0 & $\\dots$ \\\\\n",
"\t11 & Northern Territory & Australia & -12.4634 & 130.846 & 0 & $\\dots$ \\\\\n",
"\t12 & Queensland & Australia & -27.4698 & 153.025 & 0 & $\\dots$ \\\\\n",
"\t13 & South Australia & Australia & -34.9285 & 138.601 & 0 & $\\dots$ \\\\\n",
"\t14 & Tasmania & Australia & -42.8821 & 147.327 & 0 & $\\dots$ \\\\\n",
"\t15 & Victoria & Australia & -37.8136 & 144.963 & 0 & $\\dots$ \\\\\n",
"\t16 & Western Australia & Australia & -31.9505 & 115.861 & 0 & $\\dots$ \\\\\n",
"\t17 & \\emph{missing} & Austria & 47.5162 & 14.5501 & 0 & $\\dots$ \\\\\n",
"\t18 & \\emph{missing} & Azerbaijan & 40.1431 & 47.5769 & 0 & $\\dots$ \\\\\n",
"\t19 & \\emph{missing} & Bahamas & 25.0259 & -78.0359 & 0 & $\\dots$ \\\\\n",
"\t20 & \\emph{missing} & Bahrain & 26.0275 & 50.55 & 0 & $\\dots$ \\\\\n",
"\t21 & \\emph{missing} & Bangladesh & 23.685 & 90.3563 & 0 & $\\dots$ \\\\\n",
"\t22 & \\emph{missing} & Barbados & 13.1939 & -59.5432 & 0 & $\\dots$ \\\\\n",
"\t23 & \\emph{missing} & Belarus & 53.7098 & 27.9534 & 0 & $\\dots$ \\\\\n",
"\t24 & \\emph{missing} & Belgium & 50.8333 & 4.46994 & 0 & $\\dots$ \\\\\n",
"\t25 & \\emph{missing} & Belize & 17.1899 & -88.4976 & 0 & $\\dots$ \\\\\n",
"\t26 & \\emph{missing} & Benin & 9.3077 & 2.3158 & 0 & $\\dots$ \\\\\n",
"\t27 & \\emph{missing} & Bhutan & 27.5142 & 90.4336 & 0 & $\\dots$ \\\\\n",
"\t28 & \\emph{missing} & Bolivia & -16.2902 & -63.5887 & 0 & $\\dots$ \\\\\n",
"\t29 & \\emph{missing} & Bosnia and Herzegovina & 43.9159 & 17.6791 & 0 & $\\dots$ \\\\\n",
"\t30 & \\emph{missing} & Botswana & -22.3285 & 24.6849 & 0 & $\\dots$ \\\\\n",
"\t$\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"\u001b[1m271×347 DataFrame\u001b[0m\n",
"\u001b[1m Row \u001b[0m│\u001b[1m Province/State \u001b[0m\u001b[1m Country/Region \u001b[0m\u001b[1m Lat \u001b[0m\u001b[1m Long \u001b[0m\u001b[1m \u001b[0m ⋯\n",
"\u001b[1m \u001b[0m│\u001b[90m String? \u001b[0m\u001b[90m String \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m \u001b[0m ⋯\n",
"─────┼──────────────────────────────────────────────────────────────────────────\n",
" 1 │\u001b[90m missing \u001b[0m Afghanistan 33.9391 67.71 ⋯\n",
" 2 │\u001b[90m missing \u001b[0m Albania 41.1533 20.1683\n",
" 3 │\u001b[90m missing \u001b[0m Algeria 28.0339 1.6596\n",
" 4 │\u001b[90m missing \u001b[0m Andorra 42.5063 1.5218\n",
" 5 │\u001b[90m missing \u001b[0m Angola -11.2027 17.8739 ⋯\n",
" 6 │\u001b[90m missing \u001b[0m Antigua and Barbuda 17.0608 -61.7964\n",
" 7 │\u001b[90m missing \u001b[0m Argentina -38.4161 -63.6167\n",
" 8 │\u001b[90m missing \u001b[0m Armenia 40.0691 45.0382\n",
" 9 │ Australian Capital Territory Australia -35.4735 149.012 ⋯\n",
" 10 │ New South Wales Australia -33.8688 151.209\n",
" 11 │ Northern Territory Australia -12.4634 130.846\n",
" ⋮ │ ⋮ ⋮ ⋮ ⋮ ⋱\n",
" 262 │\u001b[90m missing \u001b[0m United Kingdom 55.3781 -3.436\n",
" 263 │\u001b[90m missing \u001b[0m Uruguay -32.5228 -55.7658 ⋯\n",
" 264 │\u001b[90m missing \u001b[0m Uzbekistan 41.3775 64.5853\n",
" 265 │\u001b[90m missing \u001b[0m Vanuatu -15.3767 166.959\n",
" 266 │\u001b[90m missing \u001b[0m Venezuela 6.4238 -66.5897\n",
" 267 │\u001b[90m missing \u001b[0m Vietnam 14.0583 108.277 ⋯\n",
" 268 │\u001b[90m missing \u001b[0m West Bank and Gaza 31.9522 35.2332\n",
" 269 │\u001b[90m missing \u001b[0m Yemen 15.5527 48.5164\n",
" 270 │\u001b[90m missing \u001b[0m Zambia -13.1339 27.8493\n",
" 271 │\u001b[90m missing \u001b[0m Zimbabwe -19.0154 29.1549 ⋯\n",
"\u001b[31m 343 columns and 250 rows omitted\u001b[0m"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data = CSV.read(\"covid_data.csv\", DataFrame)\n",
"data"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"DataFrame"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"typeof(data)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can rename each column name."
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"province country Lat Long 1/22/20 String? String Float64? Float64? Int64 271 rows × 347 columns (omitted printing of 342 columns)
1 missing Afghanistan 33.9391 67.71 0 2 missing Albania 41.1533 20.1683 0 3 missing Algeria 28.0339 1.6596 0 4 missing Andorra 42.5063 1.5218 0 5 missing Angola -11.2027 17.8739 0 6 missing Antigua and Barbuda 17.0608 -61.7964 0 7 missing Argentina -38.4161 -63.6167 0 8 missing Armenia 40.0691 45.0382 0 9 Australian Capital Territory Australia -35.4735 149.012 0 10 New South Wales Australia -33.8688 151.209 0 11 Northern Territory Australia -12.4634 130.846 0 12 Queensland Australia -27.4698 153.025 0 13 South Australia Australia -34.9285 138.601 0 14 Tasmania Australia -42.8821 147.327 0 15 Victoria Australia -37.8136 144.963 0 16 Western Australia Australia -31.9505 115.861 0 17 missing Austria 47.5162 14.5501 0 18 missing Azerbaijan 40.1431 47.5769 0 19 missing Bahamas 25.0259 -78.0359 0 20 missing Bahrain 26.0275 50.55 0 21 missing Bangladesh 23.685 90.3563 0 22 missing Barbados 13.1939 -59.5432 0 23 missing Belarus 53.7098 27.9534 0 24 missing Belgium 50.8333 4.46994 0 25 missing Belize 17.1899 -88.4976 0 26 missing Benin 9.3077 2.3158 0 27 missing Bhutan 27.5142 90.4336 0 28 missing Bolivia -16.2902 -63.5887 0 29 missing Bosnia and Herzegovina 43.9159 17.6791 0 30 missing Botswana -22.3285 24.6849 0 ⋮ ⋮ ⋮ ⋮ ⋮ ⋮
"
],
"text/latex": [
"\\begin{tabular}{r|cccccc}\n",
"\t& province & country & Lat & Long & 1/22/20 & \\\\\n",
"\t\\hline\n",
"\t& String? & String & Float64? & Float64? & Int64 & \\\\\n",
"\t\\hline\n",
"\t1 & \\emph{missing} & Afghanistan & 33.9391 & 67.71 & 0 & $\\dots$ \\\\\n",
"\t2 & \\emph{missing} & Albania & 41.1533 & 20.1683 & 0 & $\\dots$ \\\\\n",
"\t3 & \\emph{missing} & Algeria & 28.0339 & 1.6596 & 0 & $\\dots$ \\\\\n",
"\t4 & \\emph{missing} & Andorra & 42.5063 & 1.5218 & 0 & $\\dots$ \\\\\n",
"\t5 & \\emph{missing} & Angola & -11.2027 & 17.8739 & 0 & $\\dots$ \\\\\n",
"\t6 & \\emph{missing} & Antigua and Barbuda & 17.0608 & -61.7964 & 0 & $\\dots$ \\\\\n",
"\t7 & \\emph{missing} & Argentina & -38.4161 & -63.6167 & 0 & $\\dots$ \\\\\n",
"\t8 & \\emph{missing} & Armenia & 40.0691 & 45.0382 & 0 & $\\dots$ \\\\\n",
"\t9 & Australian Capital Territory & Australia & -35.4735 & 149.012 & 0 & $\\dots$ \\\\\n",
"\t10 & New South Wales & Australia & -33.8688 & 151.209 & 0 & $\\dots$ \\\\\n",
"\t11 & Northern Territory & Australia & -12.4634 & 130.846 & 0 & $\\dots$ \\\\\n",
"\t12 & Queensland & Australia & -27.4698 & 153.025 & 0 & $\\dots$ \\\\\n",
"\t13 & South Australia & Australia & -34.9285 & 138.601 & 0 & $\\dots$ \\\\\n",
"\t14 & Tasmania & Australia & -42.8821 & 147.327 & 0 & $\\dots$ \\\\\n",
"\t15 & Victoria & Australia & -37.8136 & 144.963 & 0 & $\\dots$ \\\\\n",
"\t16 & Western Australia & Australia & -31.9505 & 115.861 & 0 & $\\dots$ \\\\\n",
"\t17 & \\emph{missing} & Austria & 47.5162 & 14.5501 & 0 & $\\dots$ \\\\\n",
"\t18 & \\emph{missing} & Azerbaijan & 40.1431 & 47.5769 & 0 & $\\dots$ \\\\\n",
"\t19 & \\emph{missing} & Bahamas & 25.0259 & -78.0359 & 0 & $\\dots$ \\\\\n",
"\t20 & \\emph{missing} & Bahrain & 26.0275 & 50.55 & 0 & $\\dots$ \\\\\n",
"\t21 & \\emph{missing} & Bangladesh & 23.685 & 90.3563 & 0 & $\\dots$ \\\\\n",
"\t22 & \\emph{missing} & Barbados & 13.1939 & -59.5432 & 0 & $\\dots$ \\\\\n",
"\t23 & \\emph{missing} & Belarus & 53.7098 & 27.9534 & 0 & $\\dots$ \\\\\n",
"\t24 & \\emph{missing} & Belgium & 50.8333 & 4.46994 & 0 & $\\dots$ \\\\\n",
"\t25 & \\emph{missing} & Belize & 17.1899 & -88.4976 & 0 & $\\dots$ \\\\\n",
"\t26 & \\emph{missing} & Benin & 9.3077 & 2.3158 & 0 & $\\dots$ \\\\\n",
"\t27 & \\emph{missing} & Bhutan & 27.5142 & 90.4336 & 0 & $\\dots$ \\\\\n",
"\t28 & \\emph{missing} & Bolivia & -16.2902 & -63.5887 & 0 & $\\dots$ \\\\\n",
"\t29 & \\emph{missing} & Bosnia and Herzegovina & 43.9159 & 17.6791 & 0 & $\\dots$ \\\\\n",
"\t30 & \\emph{missing} & Botswana & -22.3285 & 24.6849 & 0 & $\\dots$ \\\\\n",
"\t$\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"\u001b[1m271×347 DataFrame\u001b[0m\n",
"\u001b[1m Row \u001b[0m│\u001b[1m province \u001b[0m\u001b[1m country \u001b[0m\u001b[1m Lat \u001b[0m\u001b[1m Long \u001b[0m\u001b[1m \u001b[0m ⋯\n",
"\u001b[1m \u001b[0m│\u001b[90m String? \u001b[0m\u001b[90m String \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m \u001b[0m ⋯\n",
"─────┼──────────────────────────────────────────────────────────────────────────\n",
" 1 │\u001b[90m missing \u001b[0m Afghanistan 33.9391 67.71 ⋯\n",
" 2 │\u001b[90m missing \u001b[0m Albania 41.1533 20.1683\n",
" 3 │\u001b[90m missing \u001b[0m Algeria 28.0339 1.6596\n",
" 4 │\u001b[90m missing \u001b[0m Andorra 42.5063 1.5218\n",
" 5 │\u001b[90m missing \u001b[0m Angola -11.2027 17.8739 ⋯\n",
" 6 │\u001b[90m missing \u001b[0m Antigua and Barbuda 17.0608 -61.7964\n",
" 7 │\u001b[90m missing \u001b[0m Argentina -38.4161 -63.6167\n",
" 8 │\u001b[90m missing \u001b[0m Armenia 40.0691 45.0382\n",
" 9 │ Australian Capital Territory Australia -35.4735 149.012 ⋯\n",
" 10 │ New South Wales Australia -33.8688 151.209\n",
" 11 │ Northern Territory Australia -12.4634 130.846\n",
" ⋮ │ ⋮ ⋮ ⋮ ⋮ ⋱\n",
" 262 │\u001b[90m missing \u001b[0m United Kingdom 55.3781 -3.436\n",
" 263 │\u001b[90m missing \u001b[0m Uruguay -32.5228 -55.7658 ⋯\n",
" 264 │\u001b[90m missing \u001b[0m Uzbekistan 41.3775 64.5853\n",
" 265 │\u001b[90m missing \u001b[0m Vanuatu -15.3767 166.959\n",
" 266 │\u001b[90m missing \u001b[0m Venezuela 6.4238 -66.5897\n",
" 267 │\u001b[90m missing \u001b[0m Vietnam 14.0583 108.277 ⋯\n",
" 268 │\u001b[90m missing \u001b[0m West Bank and Gaza 31.9522 35.2332\n",
" 269 │\u001b[90m missing \u001b[0m Yemen 15.5527 48.5164\n",
" 270 │\u001b[90m missing \u001b[0m Zambia -13.1339 27.8493\n",
" 271 │\u001b[90m missing \u001b[0m Zimbabwe -19.0154 29.1549 ⋯\n",
"\u001b[31m 343 columns and 250 rows omitted\u001b[0m"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data_2 = rename(data, 1 => \"province\", 2 => \"country\")\n",
"data_2"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"province country Lat Long 1/22/20 String? String Float64? Float64? Int64 271 rows × 347 columns (omitted printing of 342 columns)
1 missing Afghanistan 33.9391 67.71 0 2 missing Albania 41.1533 20.1683 0 3 missing Algeria 28.0339 1.6596 0 4 missing Andorra 42.5063 1.5218 0 5 missing Angola -11.2027 17.8739 0 6 missing Antigua and Barbuda 17.0608 -61.7964 0 7 missing Argentina -38.4161 -63.6167 0 8 missing Armenia 40.0691 45.0382 0 9 Australian Capital Territory Australia -35.4735 149.012 0 10 New South Wales Australia -33.8688 151.209 0 11 Northern Territory Australia -12.4634 130.846 0 12 Queensland Australia -27.4698 153.025 0 13 South Australia Australia -34.9285 138.601 0 14 Tasmania Australia -42.8821 147.327 0 15 Victoria Australia -37.8136 144.963 0 16 Western Australia Australia -31.9505 115.861 0 17 missing Austria 47.5162 14.5501 0 18 missing Azerbaijan 40.1431 47.5769 0 19 missing Bahamas 25.0259 -78.0359 0 20 missing Bahrain 26.0275 50.55 0 21 missing Bangladesh 23.685 90.3563 0 22 missing Barbados 13.1939 -59.5432 0 23 missing Belarus 53.7098 27.9534 0 24 missing Belgium 50.8333 4.46994 0 25 missing Belize 17.1899 -88.4976 0 26 missing Benin 9.3077 2.3158 0 27 missing Bhutan 27.5142 90.4336 0 28 missing Bolivia -16.2902 -63.5887 0 29 missing Bosnia and Herzegovina 43.9159 17.6791 0 30 missing Botswana -22.3285 24.6849 0 ⋮ ⋮ ⋮ ⋮ ⋮ ⋮
"
],
"text/latex": [
"\\begin{tabular}{r|cccccc}\n",
"\t& province & country & Lat & Long & 1/22/20 & \\\\\n",
"\t\\hline\n",
"\t& String? & String & Float64? & Float64? & Int64 & \\\\\n",
"\t\\hline\n",
"\t1 & \\emph{missing} & Afghanistan & 33.9391 & 67.71 & 0 & $\\dots$ \\\\\n",
"\t2 & \\emph{missing} & Albania & 41.1533 & 20.1683 & 0 & $\\dots$ \\\\\n",
"\t3 & \\emph{missing} & Algeria & 28.0339 & 1.6596 & 0 & $\\dots$ \\\\\n",
"\t4 & \\emph{missing} & Andorra & 42.5063 & 1.5218 & 0 & $\\dots$ \\\\\n",
"\t5 & \\emph{missing} & Angola & -11.2027 & 17.8739 & 0 & $\\dots$ \\\\\n",
"\t6 & \\emph{missing} & Antigua and Barbuda & 17.0608 & -61.7964 & 0 & $\\dots$ \\\\\n",
"\t7 & \\emph{missing} & Argentina & -38.4161 & -63.6167 & 0 & $\\dots$ \\\\\n",
"\t8 & \\emph{missing} & Armenia & 40.0691 & 45.0382 & 0 & $\\dots$ \\\\\n",
"\t9 & Australian Capital Territory & Australia & -35.4735 & 149.012 & 0 & $\\dots$ \\\\\n",
"\t10 & New South Wales & Australia & -33.8688 & 151.209 & 0 & $\\dots$ \\\\\n",
"\t11 & Northern Territory & Australia & -12.4634 & 130.846 & 0 & $\\dots$ \\\\\n",
"\t12 & Queensland & Australia & -27.4698 & 153.025 & 0 & $\\dots$ \\\\\n",
"\t13 & South Australia & Australia & -34.9285 & 138.601 & 0 & $\\dots$ \\\\\n",
"\t14 & Tasmania & Australia & -42.8821 & 147.327 & 0 & $\\dots$ \\\\\n",
"\t15 & Victoria & Australia & -37.8136 & 144.963 & 0 & $\\dots$ \\\\\n",
"\t16 & Western Australia & Australia & -31.9505 & 115.861 & 0 & $\\dots$ \\\\\n",
"\t17 & \\emph{missing} & Austria & 47.5162 & 14.5501 & 0 & $\\dots$ \\\\\n",
"\t18 & \\emph{missing} & Azerbaijan & 40.1431 & 47.5769 & 0 & $\\dots$ \\\\\n",
"\t19 & \\emph{missing} & Bahamas & 25.0259 & -78.0359 & 0 & $\\dots$ \\\\\n",
"\t20 & \\emph{missing} & Bahrain & 26.0275 & 50.55 & 0 & $\\dots$ \\\\\n",
"\t21 & \\emph{missing} & Bangladesh & 23.685 & 90.3563 & 0 & $\\dots$ \\\\\n",
"\t22 & \\emph{missing} & Barbados & 13.1939 & -59.5432 & 0 & $\\dots$ \\\\\n",
"\t23 & \\emph{missing} & Belarus & 53.7098 & 27.9534 & 0 & $\\dots$ \\\\\n",
"\t24 & \\emph{missing} & Belgium & 50.8333 & 4.46994 & 0 & $\\dots$ \\\\\n",
"\t25 & \\emph{missing} & Belize & 17.1899 & -88.4976 & 0 & $\\dots$ \\\\\n",
"\t26 & \\emph{missing} & Benin & 9.3077 & 2.3158 & 0 & $\\dots$ \\\\\n",
"\t27 & \\emph{missing} & Bhutan & 27.5142 & 90.4336 & 0 & $\\dots$ \\\\\n",
"\t28 & \\emph{missing} & Bolivia & -16.2902 & -63.5887 & 0 & $\\dots$ \\\\\n",
"\t29 & \\emph{missing} & Bosnia and Herzegovina & 43.9159 & 17.6791 & 0 & $\\dots$ \\\\\n",
"\t30 & \\emph{missing} & Botswana & -22.3285 & 24.6849 & 0 & $\\dots$ \\\\\n",
"\t$\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"\u001b[1m271×347 DataFrame\u001b[0m\n",
"\u001b[1m Row \u001b[0m│\u001b[1m province \u001b[0m\u001b[1m country \u001b[0m\u001b[1m Lat \u001b[0m\u001b[1m Long \u001b[0m\u001b[1m \u001b[0m ⋯\n",
"\u001b[1m \u001b[0m│\u001b[90m String? \u001b[0m\u001b[90m String \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m \u001b[0m ⋯\n",
"─────┼──────────────────────────────────────────────────────────────────────────\n",
" 1 │\u001b[90m missing \u001b[0m Afghanistan 33.9391 67.71 ⋯\n",
" 2 │\u001b[90m missing \u001b[0m Albania 41.1533 20.1683\n",
" 3 │\u001b[90m missing \u001b[0m Algeria 28.0339 1.6596\n",
" 4 │\u001b[90m missing \u001b[0m Andorra 42.5063 1.5218\n",
" 5 │\u001b[90m missing \u001b[0m Angola -11.2027 17.8739 ⋯\n",
" 6 │\u001b[90m missing \u001b[0m Antigua and Barbuda 17.0608 -61.7964\n",
" 7 │\u001b[90m missing \u001b[0m Argentina -38.4161 -63.6167\n",
" 8 │\u001b[90m missing \u001b[0m Armenia 40.0691 45.0382\n",
" 9 │ Australian Capital Territory Australia -35.4735 149.012 ⋯\n",
" 10 │ New South Wales Australia -33.8688 151.209\n",
" 11 │ Northern Territory Australia -12.4634 130.846\n",
" ⋮ │ ⋮ ⋮ ⋮ ⋮ ⋱\n",
" 262 │\u001b[90m missing \u001b[0m United Kingdom 55.3781 -3.436\n",
" 263 │\u001b[90m missing \u001b[0m Uruguay -32.5228 -55.7658 ⋯\n",
" 264 │\u001b[90m missing \u001b[0m Uzbekistan 41.3775 64.5853\n",
" 265 │\u001b[90m missing \u001b[0m Vanuatu -15.3767 166.959\n",
" 266 │\u001b[90m missing \u001b[0m Venezuela 6.4238 -66.5897\n",
" 267 │\u001b[90m missing \u001b[0m Vietnam 14.0583 108.277 ⋯\n",
" 268 │\u001b[90m missing \u001b[0m West Bank and Gaza 31.9522 35.2332\n",
" 269 │\u001b[90m missing \u001b[0m Yemen 15.5527 48.5164\n",
" 270 │\u001b[90m missing \u001b[0m Zambia -13.1339 27.8493\n",
" 271 │\u001b[90m missing \u001b[0m Zimbabwe -19.0154 29.1549 ⋯\n",
"\u001b[31m 343 columns and 250 rows omitted\u001b[0m"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# ! is convention: function *modifies* its argument in place\n",
"rename!(data, 1 => \"province\", 2 => \"country\") "
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"province country Lat Long 1/22/20 String? String Float64? Float64? Int64 271 rows × 347 columns (omitted printing of 342 columns)
1 missing Afghanistan 33.9391 67.71 0 2 missing Albania 41.1533 20.1683 0 3 missing Algeria 28.0339 1.6596 0 4 missing Andorra 42.5063 1.5218 0 5 missing Angola -11.2027 17.8739 0 6 missing Antigua and Barbuda 17.0608 -61.7964 0 7 missing Argentina -38.4161 -63.6167 0 8 missing Armenia 40.0691 45.0382 0 9 Australian Capital Territory Australia -35.4735 149.012 0 10 New South Wales Australia -33.8688 151.209 0 11 Northern Territory Australia -12.4634 130.846 0 12 Queensland Australia -27.4698 153.025 0 13 South Australia Australia -34.9285 138.601 0 14 Tasmania Australia -42.8821 147.327 0 15 Victoria Australia -37.8136 144.963 0 16 Western Australia Australia -31.9505 115.861 0 17 missing Austria 47.5162 14.5501 0 18 missing Azerbaijan 40.1431 47.5769 0 19 missing Bahamas 25.0259 -78.0359 0 20 missing Bahrain 26.0275 50.55 0 21 missing Bangladesh 23.685 90.3563 0 22 missing Barbados 13.1939 -59.5432 0 23 missing Belarus 53.7098 27.9534 0 24 missing Belgium 50.8333 4.46994 0 25 missing Belize 17.1899 -88.4976 0 26 missing Benin 9.3077 2.3158 0 27 missing Bhutan 27.5142 90.4336 0 28 missing Bolivia -16.2902 -63.5887 0 29 missing Bosnia and Herzegovina 43.9159 17.6791 0 30 missing Botswana -22.3285 24.6849 0 ⋮ ⋮ ⋮ ⋮ ⋮ ⋮
"
],
"text/latex": [
"\\begin{tabular}{r|cccccc}\n",
"\t& province & country & Lat & Long & 1/22/20 & \\\\\n",
"\t\\hline\n",
"\t& String? & String & Float64? & Float64? & Int64 & \\\\\n",
"\t\\hline\n",
"\t1 & \\emph{missing} & Afghanistan & 33.9391 & 67.71 & 0 & $\\dots$ \\\\\n",
"\t2 & \\emph{missing} & Albania & 41.1533 & 20.1683 & 0 & $\\dots$ \\\\\n",
"\t3 & \\emph{missing} & Algeria & 28.0339 & 1.6596 & 0 & $\\dots$ \\\\\n",
"\t4 & \\emph{missing} & Andorra & 42.5063 & 1.5218 & 0 & $\\dots$ \\\\\n",
"\t5 & \\emph{missing} & Angola & -11.2027 & 17.8739 & 0 & $\\dots$ \\\\\n",
"\t6 & \\emph{missing} & Antigua and Barbuda & 17.0608 & -61.7964 & 0 & $\\dots$ \\\\\n",
"\t7 & \\emph{missing} & Argentina & -38.4161 & -63.6167 & 0 & $\\dots$ \\\\\n",
"\t8 & \\emph{missing} & Armenia & 40.0691 & 45.0382 & 0 & $\\dots$ \\\\\n",
"\t9 & Australian Capital Territory & Australia & -35.4735 & 149.012 & 0 & $\\dots$ \\\\\n",
"\t10 & New South Wales & Australia & -33.8688 & 151.209 & 0 & $\\dots$ \\\\\n",
"\t11 & Northern Territory & Australia & -12.4634 & 130.846 & 0 & $\\dots$ \\\\\n",
"\t12 & Queensland & Australia & -27.4698 & 153.025 & 0 & $\\dots$ \\\\\n",
"\t13 & South Australia & Australia & -34.9285 & 138.601 & 0 & $\\dots$ \\\\\n",
"\t14 & Tasmania & Australia & -42.8821 & 147.327 & 0 & $\\dots$ \\\\\n",
"\t15 & Victoria & Australia & -37.8136 & 144.963 & 0 & $\\dots$ \\\\\n",
"\t16 & Western Australia & Australia & -31.9505 & 115.861 & 0 & $\\dots$ \\\\\n",
"\t17 & \\emph{missing} & Austria & 47.5162 & 14.5501 & 0 & $\\dots$ \\\\\n",
"\t18 & \\emph{missing} & Azerbaijan & 40.1431 & 47.5769 & 0 & $\\dots$ \\\\\n",
"\t19 & \\emph{missing} & Bahamas & 25.0259 & -78.0359 & 0 & $\\dots$ \\\\\n",
"\t20 & \\emph{missing} & Bahrain & 26.0275 & 50.55 & 0 & $\\dots$ \\\\\n",
"\t21 & \\emph{missing} & Bangladesh & 23.685 & 90.3563 & 0 & $\\dots$ \\\\\n",
"\t22 & \\emph{missing} & Barbados & 13.1939 & -59.5432 & 0 & $\\dots$ \\\\\n",
"\t23 & \\emph{missing} & Belarus & 53.7098 & 27.9534 & 0 & $\\dots$ \\\\\n",
"\t24 & \\emph{missing} & Belgium & 50.8333 & 4.46994 & 0 & $\\dots$ \\\\\n",
"\t25 & \\emph{missing} & Belize & 17.1899 & -88.4976 & 0 & $\\dots$ \\\\\n",
"\t26 & \\emph{missing} & Benin & 9.3077 & 2.3158 & 0 & $\\dots$ \\\\\n",
"\t27 & \\emph{missing} & Bhutan & 27.5142 & 90.4336 & 0 & $\\dots$ \\\\\n",
"\t28 & \\emph{missing} & Bolivia & -16.2902 & -63.5887 & 0 & $\\dots$ \\\\\n",
"\t29 & \\emph{missing} & Bosnia and Herzegovina & 43.9159 & 17.6791 & 0 & $\\dots$ \\\\\n",
"\t30 & \\emph{missing} & Botswana & -22.3285 & 24.6849 & 0 & $\\dots$ \\\\\n",
"\t$\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"\u001b[1m271×347 DataFrame\u001b[0m\n",
"\u001b[1m Row \u001b[0m│\u001b[1m province \u001b[0m\u001b[1m country \u001b[0m\u001b[1m Lat \u001b[0m\u001b[1m Long \u001b[0m\u001b[1m \u001b[0m ⋯\n",
"\u001b[1m \u001b[0m│\u001b[90m String? \u001b[0m\u001b[90m String \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m \u001b[0m ⋯\n",
"─────┼──────────────────────────────────────────────────────────────────────────\n",
" 1 │\u001b[90m missing \u001b[0m Afghanistan 33.9391 67.71 ⋯\n",
" 2 │\u001b[90m missing \u001b[0m Albania 41.1533 20.1683\n",
" 3 │\u001b[90m missing \u001b[0m Algeria 28.0339 1.6596\n",
" 4 │\u001b[90m missing \u001b[0m Andorra 42.5063 1.5218\n",
" 5 │\u001b[90m missing \u001b[0m Angola -11.2027 17.8739 ⋯\n",
" 6 │\u001b[90m missing \u001b[0m Antigua and Barbuda 17.0608 -61.7964\n",
" 7 │\u001b[90m missing \u001b[0m Argentina -38.4161 -63.6167\n",
" 8 │\u001b[90m missing \u001b[0m Armenia 40.0691 45.0382\n",
" 9 │ Australian Capital Territory Australia -35.4735 149.012 ⋯\n",
" 10 │ New South Wales Australia -33.8688 151.209\n",
" 11 │ Northern Territory Australia -12.4634 130.846\n",
" ⋮ │ ⋮ ⋮ ⋮ ⋮ ⋱\n",
" 262 │\u001b[90m missing \u001b[0m United Kingdom 55.3781 -3.436\n",
" 263 │\u001b[90m missing \u001b[0m Uruguay -32.5228 -55.7658 ⋯\n",
" 264 │\u001b[90m missing \u001b[0m Uzbekistan 41.3775 64.5853\n",
" 265 │\u001b[90m missing \u001b[0m Vanuatu -15.3767 166.959\n",
" 266 │\u001b[90m missing \u001b[0m Venezuela 6.4238 -66.5897\n",
" 267 │\u001b[90m missing \u001b[0m Vietnam 14.0583 108.277 ⋯\n",
" 268 │\u001b[90m missing \u001b[0m West Bank and Gaza 31.9522 35.2332\n",
" 269 │\u001b[90m missing \u001b[0m Yemen 15.5527 48.5164\n",
" 270 │\u001b[90m missing \u001b[0m Zambia -13.1339 27.8493\n",
" 271 │\u001b[90m missing \u001b[0m Zimbabwe -19.0154 29.1549 ⋯\n",
"\u001b[31m 343 columns and 250 rows omitted\u001b[0m"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"search: \u001b[0m\u001b[1mr\u001b[22m\u001b[0m\u001b[1me\u001b[22m\u001b[0m\u001b[1mn\u001b[22m\u001b[0m\u001b[1ma\u001b[22m\u001b[0m\u001b[1mm\u001b[22m\u001b[0m\u001b[1me\u001b[22m \u001b[0m\u001b[1mr\u001b[22m\u001b[0m\u001b[1me\u001b[22m\u001b[0m\u001b[1mn\u001b[22m\u001b[0m\u001b[1ma\u001b[22m\u001b[0m\u001b[1mm\u001b[22m\u001b[0m\u001b[1me\u001b[22m! p\u001b[0m\u001b[1mr\u001b[22mop\u001b[0m\u001b[1me\u001b[22mrty\u001b[0m\u001b[1mn\u001b[22m\u001b[0m\u001b[1ma\u001b[22m\u001b[0m\u001b[1mm\u001b[22m\u001b[0m\u001b[1me\u001b[22ms\n",
"\n"
]
},
{
"data": {
"text/latex": [
"\\begin{verbatim}\n",
"rename(df::AbstractDataFrame, vals::AbstractVector{Symbol};\n",
" makeunique::Bool=false)\n",
"rename(df::AbstractDataFrame, vals::AbstractVector{<:AbstractString};\n",
" makeunique::Bool=false)\n",
"rename(df::AbstractDataFrame, (from => to)::Pair...)\n",
"rename(df::AbstractDataFrame, d::AbstractDict)\n",
"rename(df::AbstractDataFrame, d::AbstractVector{<:Pair})\n",
"rename(f::Function, df::AbstractDataFrame)\n",
"\\end{verbatim}\n",
"Create a new data frame that is a copy of \\texttt{df} with changed column names. Each name is changed at most once. Permutation of names is allowed.\n",
"\n",
"\\section{Arguments}\n",
"\\begin{itemize}\n",
"\\item \\texttt{df} : the \\texttt{AbstractDataFrame}; if it is a \\texttt{SubDataFrame} then renaming is only allowed if it was created using \\texttt{:} as a column selector.\n",
"\n",
"\n",
"\\item \\texttt{d} : an \\texttt{AbstractDict} or an \\texttt{AbstractVector} of \\texttt{Pair}s that maps the original names or column numbers to new names\n",
"\n",
"\n",
"\\item \\texttt{f} : a function which for each column takes the old name as a \\texttt{String} and returns the new name that gets converted to a \\texttt{Symbol}\n",
"\n",
"\n",
"\\item \\texttt{vals} : new column names as a vector of \\texttt{Symbol}s or \\texttt{AbstractString}s of the same length as the number of columns in \\texttt{df}\n",
"\n",
"\n",
"\\item \\texttt{makeunique} : if \\texttt{false} (the default), an error will be raised if duplicate names are found; if \\texttt{true}, duplicate names will be suffixed with \\texttt{\\_i} (\\texttt{i} starting at 1 for the first duplicate).\n",
"\n",
"\\end{itemize}\n",
"If pairs are passed to \\texttt{rename} (as positional arguments or in a dictionary or a vector) then:\n",
"\n",
"\\begin{itemize}\n",
"\\item \\texttt{from} value can be a \\texttt{Symbol}, an \\texttt{AbstractString} or an \\texttt{Integer};\n",
"\n",
"\n",
"\\item \\texttt{to} value can be a \\texttt{Symbol} or an \\texttt{AbstractString}.\n",
"\n",
"\\end{itemize}\n",
"Mixing symbols and strings in \\texttt{to} and \\texttt{from} is not allowed.\n",
"\n",
"See also: \\href{@ref}{\\texttt{rename!}}\n",
"\n",
"\\section{Examples}\n",
"\\begin{verbatim}\n",
"julia> df = DataFrame(i = 1, x = 2, y = 3)\n",
"1×3 DataFrame\n",
" Row │ i x y\n",
" │ Int64 Int64 Int64\n",
"─────┼─────────────────────\n",
" 1 │ 1 2 3\n",
"\n",
"julia> rename(df, :i => :A, :x => :X)\n",
"1×3 DataFrame\n",
" Row │ A X y\n",
" │ Int64 Int64 Int64\n",
"─────┼─────────────────────\n",
" 1 │ 1 2 3\n",
"\n",
"julia> rename(df, :x => :y, :y => :x)\n",
"1×3 DataFrame\n",
" Row │ i y x\n",
" │ Int64 Int64 Int64\n",
"─────┼─────────────────────\n",
" 1 │ 1 2 3\n",
"\n",
"julia> rename(df, [1 => :A, 2 => :X])\n",
"1×3 DataFrame\n",
" Row │ A X y\n",
" │ Int64 Int64 Int64\n",
"─────┼─────────────────────\n",
" 1 │ 1 2 3\n",
"\n",
"julia> rename(df, Dict(\"i\" => \"A\", \"x\" => \"X\"))\n",
"1×3 DataFrame\n",
" Row │ A X y\n",
" │ Int64 Int64 Int64\n",
"─────┼─────────────────────\n",
" 1 │ 1 2 3\n",
"\n",
"julia> rename(uppercase, df)\n",
"1×3 DataFrame\n",
" Row │ I X Y\n",
" │ Int64 Int64 Int64\n",
"─────┼─────────────────────\n",
" 1 │ 1 2 3\n",
"\\end{verbatim}\n"
],
"text/markdown": [
"```\n",
"rename(df::AbstractDataFrame, vals::AbstractVector{Symbol};\n",
" makeunique::Bool=false)\n",
"rename(df::AbstractDataFrame, vals::AbstractVector{<:AbstractString};\n",
" makeunique::Bool=false)\n",
"rename(df::AbstractDataFrame, (from => to)::Pair...)\n",
"rename(df::AbstractDataFrame, d::AbstractDict)\n",
"rename(df::AbstractDataFrame, d::AbstractVector{<:Pair})\n",
"rename(f::Function, df::AbstractDataFrame)\n",
"```\n",
"\n",
"Create a new data frame that is a copy of `df` with changed column names. Each name is changed at most once. Permutation of names is allowed.\n",
"\n",
"# Arguments\n",
"\n",
" * `df` : the `AbstractDataFrame`; if it is a `SubDataFrame` then renaming is only allowed if it was created using `:` as a column selector.\n",
" * `d` : an `AbstractDict` or an `AbstractVector` of `Pair`s that maps the original names or column numbers to new names\n",
" * `f` : a function which for each column takes the old name as a `String` and returns the new name that gets converted to a `Symbol`\n",
" * `vals` : new column names as a vector of `Symbol`s or `AbstractString`s of the same length as the number of columns in `df`\n",
" * `makeunique` : if `false` (the default), an error will be raised if duplicate names are found; if `true`, duplicate names will be suffixed with `_i` (`i` starting at 1 for the first duplicate).\n",
"\n",
"If pairs are passed to `rename` (as positional arguments or in a dictionary or a vector) then:\n",
"\n",
" * `from` value can be a `Symbol`, an `AbstractString` or an `Integer`;\n",
" * `to` value can be a `Symbol` or an `AbstractString`.\n",
"\n",
"Mixing symbols and strings in `to` and `from` is not allowed.\n",
"\n",
"See also: [`rename!`](@ref)\n",
"\n",
"# Examples\n",
"\n",
"```julia\n",
"julia> df = DataFrame(i = 1, x = 2, y = 3)\n",
"1×3 DataFrame\n",
" Row │ i x y\n",
" │ Int64 Int64 Int64\n",
"─────┼─────────────────────\n",
" 1 │ 1 2 3\n",
"\n",
"julia> rename(df, :i => :A, :x => :X)\n",
"1×3 DataFrame\n",
" Row │ A X y\n",
" │ Int64 Int64 Int64\n",
"─────┼─────────────────────\n",
" 1 │ 1 2 3\n",
"\n",
"julia> rename(df, :x => :y, :y => :x)\n",
"1×3 DataFrame\n",
" Row │ i y x\n",
" │ Int64 Int64 Int64\n",
"─────┼─────────────────────\n",
" 1 │ 1 2 3\n",
"\n",
"julia> rename(df, [1 => :A, 2 => :X])\n",
"1×3 DataFrame\n",
" Row │ A X y\n",
" │ Int64 Int64 Int64\n",
"─────┼─────────────────────\n",
" 1 │ 1 2 3\n",
"\n",
"julia> rename(df, Dict(\"i\" => \"A\", \"x\" => \"X\"))\n",
"1×3 DataFrame\n",
" Row │ A X y\n",
" │ Int64 Int64 Int64\n",
"─────┼─────────────────────\n",
" 1 │ 1 2 3\n",
"\n",
"julia> rename(uppercase, df)\n",
"1×3 DataFrame\n",
" Row │ I X Y\n",
" │ Int64 Int64 Int64\n",
"─────┼─────────────────────\n",
" 1 │ 1 2 3\n",
"```\n"
],
"text/plain": [
"\u001b[36m rename(df::AbstractDataFrame, vals::AbstractVector{Symbol};\u001b[39m\n",
"\u001b[36m makeunique::Bool=false)\u001b[39m\n",
"\u001b[36m rename(df::AbstractDataFrame, vals::AbstractVector{<:AbstractString};\u001b[39m\n",
"\u001b[36m makeunique::Bool=false)\u001b[39m\n",
"\u001b[36m rename(df::AbstractDataFrame, (from => to)::Pair...)\u001b[39m\n",
"\u001b[36m rename(df::AbstractDataFrame, d::AbstractDict)\u001b[39m\n",
"\u001b[36m rename(df::AbstractDataFrame, d::AbstractVector{<:Pair})\u001b[39m\n",
"\u001b[36m rename(f::Function, df::AbstractDataFrame)\u001b[39m\n",
"\n",
" Create a new data frame that is a copy of \u001b[36mdf\u001b[39m with changed column names. Each\n",
" name is changed at most once. Permutation of names is allowed.\n",
"\n",
"\u001b[1m Arguments\u001b[22m\n",
"\u001b[1m ≡≡≡≡≡≡≡≡≡≡≡\u001b[22m\n",
"\n",
" • \u001b[36mdf\u001b[39m : the \u001b[36mAbstractDataFrame\u001b[39m; if it is a \u001b[36mSubDataFrame\u001b[39m then renaming\n",
" is only allowed if it was created using \u001b[36m:\u001b[39m as a column selector.\n",
"\n",
" • \u001b[36md\u001b[39m : an \u001b[36mAbstractDict\u001b[39m or an \u001b[36mAbstractVector\u001b[39m of \u001b[36mPair\u001b[39ms that maps the\n",
" original names or column numbers to new names\n",
"\n",
" • \u001b[36mf\u001b[39m : a function which for each column takes the old name as a\n",
" \u001b[36mString\u001b[39m and returns the new name that gets converted to a \u001b[36mSymbol\u001b[39m\n",
"\n",
" • \u001b[36mvals\u001b[39m : new column names as a vector of \u001b[36mSymbol\u001b[39ms or \u001b[36mAbstractString\u001b[39ms\n",
" of the same length as the number of columns in \u001b[36mdf\u001b[39m\n",
"\n",
" • \u001b[36mmakeunique\u001b[39m : if \u001b[36mfalse\u001b[39m (the default), an error will be raised if\n",
" duplicate names are found; if \u001b[36mtrue\u001b[39m, duplicate names will be\n",
" suffixed with \u001b[36m_i\u001b[39m (\u001b[36mi\u001b[39m starting at 1 for the first duplicate).\n",
"\n",
" If pairs are passed to \u001b[36mrename\u001b[39m (as positional arguments or in a dictionary or\n",
" a vector) then:\n",
"\n",
" • \u001b[36mfrom\u001b[39m value can be a \u001b[36mSymbol\u001b[39m, an \u001b[36mAbstractString\u001b[39m or an \u001b[36mInteger\u001b[39m;\n",
"\n",
" • \u001b[36mto\u001b[39m value can be a \u001b[36mSymbol\u001b[39m or an \u001b[36mAbstractString\u001b[39m.\n",
"\n",
" Mixing symbols and strings in \u001b[36mto\u001b[39m and \u001b[36mfrom\u001b[39m is not allowed.\n",
"\n",
" See also: \u001b[36mrename!\u001b[39m\n",
"\n",
"\u001b[1m Examples\u001b[22m\n",
"\u001b[1m ≡≡≡≡≡≡≡≡≡≡\u001b[22m\n",
"\n",
"\u001b[36m julia> df = DataFrame(i = 1, x = 2, y = 3)\u001b[39m\n",
"\u001b[36m 1×3 DataFrame\u001b[39m\n",
"\u001b[36m Row │ i x y\u001b[39m\n",
"\u001b[36m │ Int64 Int64 Int64\u001b[39m\n",
"\u001b[36m ─────┼─────────────────────\u001b[39m\n",
"\u001b[36m 1 │ 1 2 3\u001b[39m\n",
"\u001b[36m \u001b[39m\n",
"\u001b[36m julia> rename(df, :i => :A, :x => :X)\u001b[39m\n",
"\u001b[36m 1×3 DataFrame\u001b[39m\n",
"\u001b[36m Row │ A X y\u001b[39m\n",
"\u001b[36m │ Int64 Int64 Int64\u001b[39m\n",
"\u001b[36m ─────┼─────────────────────\u001b[39m\n",
"\u001b[36m 1 │ 1 2 3\u001b[39m\n",
"\u001b[36m \u001b[39m\n",
"\u001b[36m julia> rename(df, :x => :y, :y => :x)\u001b[39m\n",
"\u001b[36m 1×3 DataFrame\u001b[39m\n",
"\u001b[36m Row │ i y x\u001b[39m\n",
"\u001b[36m │ Int64 Int64 Int64\u001b[39m\n",
"\u001b[36m ─────┼─────────────────────\u001b[39m\n",
"\u001b[36m 1 │ 1 2 3\u001b[39m\n",
"\u001b[36m \u001b[39m\n",
"\u001b[36m julia> rename(df, [1 => :A, 2 => :X])\u001b[39m\n",
"\u001b[36m 1×3 DataFrame\u001b[39m\n",
"\u001b[36m Row │ A X y\u001b[39m\n",
"\u001b[36m │ Int64 Int64 Int64\u001b[39m\n",
"\u001b[36m ─────┼─────────────────────\u001b[39m\n",
"\u001b[36m 1 │ 1 2 3\u001b[39m\n",
"\u001b[36m \u001b[39m\n",
"\u001b[36m julia> rename(df, Dict(\"i\" => \"A\", \"x\" => \"X\"))\u001b[39m\n",
"\u001b[36m 1×3 DataFrame\u001b[39m\n",
"\u001b[36m Row │ A X y\u001b[39m\n",
"\u001b[36m │ Int64 Int64 Int64\u001b[39m\n",
"\u001b[36m ─────┼─────────────────────\u001b[39m\n",
"\u001b[36m 1 │ 1 2 3\u001b[39m\n",
"\u001b[36m \u001b[39m\n",
"\u001b[36m julia> rename(uppercase, df)\u001b[39m\n",
"\u001b[36m 1×3 DataFrame\u001b[39m\n",
"\u001b[36m Row │ I X Y\u001b[39m\n",
"\u001b[36m │ Int64 Int64 Int64\u001b[39m\n",
"\u001b[36m ─────┼─────────────────────\u001b[39m\n",
"\u001b[36m 1 │ 1 2 3\u001b[39m"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"?rename"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Interact.jl: Simple interactive visualizations"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m\u001b[1m Resolving\u001b[22m\u001b[39m package versions...\n",
"\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `C:\\Users\\kcsgo\\.julia\\environments\\v1.4\\Project.toml`\n",
"\u001b[90m [no changes]\u001b[39m\n",
"\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `C:\\Users\\kcsgo\\.julia\\environments\\v1.4\\Manifest.toml`\n",
"\u001b[90m [no changes]\u001b[39m\n"
]
}
],
"source": [
"Pkg.add(\"Interact\")"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
" Unable to load WebIO. Please make sure WebIO works for your Jupyter client.\n",
" For troubleshooting, please see \n",
" the WebIO/IJulia documentation .\n",
" \n",
"
\n"
],
"text/plain": [
"HTML{String}(\"\\n\\n Unable to load WebIO. Please make sure WebIO works for your Jupyter client.\\n For troubleshooting, please see \\n the WebIO/IJulia documentation .\\n \\n
\\n\")"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"using Interact"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"i = 1\n",
"i = 2\n",
"i = 3\n",
"i = 4\n",
"i = 5\n",
"i = 6\n",
"i = 7\n",
"i = 8\n",
"i = 9\n",
"i = 10\n"
]
}
],
"source": [
"for i in 1:10\n",
" @show i\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"UnitRange{Int64}"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"typeof(1:10)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"10-element Array{Int64,1}:\n",
" 1\n",
" 2\n",
" 3\n",
" 4\n",
" 5\n",
" 6\n",
" 7\n",
" 8\n",
" 9\n",
" 10"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"collect(1:10)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"i = 1\n",
"i = 2\n",
"i = 3\n",
"i = 4\n",
"i = 5\n",
"i = 6\n",
"i = 7\n",
"i = 8\n",
"i = 9\n",
"i = 10\n"
]
}
],
"source": [
"for i in 1:10\n",
" println(\"i = \", i)\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4-element Array{String,1}:\n",
" \"Albania\"\n",
" \"Algeria\"\n",
" \"Andorra\"\n",
" \"Angola\""
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"countries = data[2:5, 2]"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"271-element Array{String,1}:\n",
" \"Afghanistan\"\n",
" \"Albania\"\n",
" \"Algeria\"\n",
" \"Andorra\"\n",
" \"Angola\"\n",
" \"Antigua and Barbuda\"\n",
" \"Argentina\"\n",
" \"Armenia\"\n",
" \"Australia\"\n",
" \"Australia\"\n",
" \"Australia\"\n",
" \"Australia\"\n",
" \"Australia\"\n",
" ⋮\n",
" \"United Kingdom\"\n",
" \"United Kingdom\"\n",
" \"United Kingdom\"\n",
" \"Uruguay\"\n",
" \"Uzbekistan\"\n",
" \"Vanuatu\"\n",
" \"Venezuela\"\n",
" \"Vietnam\"\n",
" \"West Bank and Gaza\"\n",
" \"Yemen\"\n",
" \"Zambia\"\n",
" \"Zimbabwe\""
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"countries = data[1:end, 2]"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"271-element Array{String,1}:\n",
" \"Afghanistan\"\n",
" \"Albania\"\n",
" \"Algeria\"\n",
" \"Andorra\"\n",
" \"Angola\"\n",
" \"Antigua and Barbuda\"\n",
" \"Argentina\"\n",
" \"Armenia\"\n",
" \"Australia\"\n",
" \"Australia\"\n",
" \"Australia\"\n",
" \"Australia\"\n",
" \"Australia\"\n",
" ⋮\n",
" \"United Kingdom\"\n",
" \"United Kingdom\"\n",
" \"United Kingdom\"\n",
" \"Uruguay\"\n",
" \"Uzbekistan\"\n",
" \"Vanuatu\"\n",
" \"Venezuela\"\n",
" \"Vietnam\"\n",
" \"West Bank and Gaza\"\n",
" \"Yemen\"\n",
" \"Zambia\"\n",
" \"Zimbabwe\""
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"countries = collect(data[:, 2])"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"191-element Array{String,1}:\n",
" \"Afghanistan\"\n",
" \"Albania\"\n",
" \"Algeria\"\n",
" \"Andorra\"\n",
" \"Angola\"\n",
" \"Antigua and Barbuda\"\n",
" \"Argentina\"\n",
" \"Armenia\"\n",
" \"Australia\"\n",
" \"Austria\"\n",
" \"Azerbaijan\"\n",
" \"Bahamas\"\n",
" \"Bahrain\"\n",
" ⋮\n",
" \"Ukraine\"\n",
" \"United Arab Emirates\"\n",
" \"United Kingdom\"\n",
" \"Uruguay\"\n",
" \"Uzbekistan\"\n",
" \"Vanuatu\"\n",
" \"Venezuela\"\n",
" \"Vietnam\"\n",
" \"West Bank and Gaza\"\n",
" \"Yemen\"\n",
" \"Zambia\"\n",
" \"Zimbabwe\""
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"unique_countries = unique(countries)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> Note: Julia has 1-based indexing: indices of vectors start at 1, not 0"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Extract data and plot"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"startswith(\"United\", \"U\")"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"false"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"startswith(\"David\", \"U\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Array comprehension:"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"271-element Array{Bool,1}:\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" ⋮\n",
" 1\n",
" 1\n",
" 1\n",
" 1\n",
" 1\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"U_countries = [startswith(country, \"U\") for country in countries]"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"province country Lat Long 1/22/20 String? String Float64? Float64? Int64 17 rows × 347 columns (omitted printing of 342 columns)
1 missing US 40.0 -100.0 1 2 missing Uganda 1.37333 32.2903 0 3 missing Ukraine 48.3794 31.1656 0 4 missing United Arab Emirates 23.4241 53.8478 0 5 Anguilla United Kingdom 18.2206 -63.0686 0 6 Bermuda United Kingdom 32.3078 -64.7505 0 7 British Virgin Islands United Kingdom 18.4207 -64.64 0 8 Cayman Islands United Kingdom 19.3133 -81.2546 0 9 Channel Islands United Kingdom 49.3723 -2.3644 0 10 Falkland Islands (Malvinas) United Kingdom -51.7963 -59.5236 0 11 Gibraltar United Kingdom 36.1408 -5.3536 0 12 Isle of Man United Kingdom 54.2361 -4.5481 0 13 Montserrat United Kingdom 16.7425 -62.1874 0 14 Turks and Caicos Islands United Kingdom 21.694 -71.7979 0 15 missing United Kingdom 55.3781 -3.436 0 16 missing Uruguay -32.5228 -55.7658 0 17 missing Uzbekistan 41.3775 64.5853 0
"
],
"text/latex": [
"\\begin{tabular}{r|cccccc}\n",
"\t& province & country & Lat & Long & 1/22/20 & \\\\\n",
"\t\\hline\n",
"\t& String? & String & Float64? & Float64? & Int64 & \\\\\n",
"\t\\hline\n",
"\t1 & \\emph{missing} & US & 40.0 & -100.0 & 1 & $\\dots$ \\\\\n",
"\t2 & \\emph{missing} & Uganda & 1.37333 & 32.2903 & 0 & $\\dots$ \\\\\n",
"\t3 & \\emph{missing} & Ukraine & 48.3794 & 31.1656 & 0 & $\\dots$ \\\\\n",
"\t4 & \\emph{missing} & United Arab Emirates & 23.4241 & 53.8478 & 0 & $\\dots$ \\\\\n",
"\t5 & Anguilla & United Kingdom & 18.2206 & -63.0686 & 0 & $\\dots$ \\\\\n",
"\t6 & Bermuda & United Kingdom & 32.3078 & -64.7505 & 0 & $\\dots$ \\\\\n",
"\t7 & British Virgin Islands & United Kingdom & 18.4207 & -64.64 & 0 & $\\dots$ \\\\\n",
"\t8 & Cayman Islands & United Kingdom & 19.3133 & -81.2546 & 0 & $\\dots$ \\\\\n",
"\t9 & Channel Islands & United Kingdom & 49.3723 & -2.3644 & 0 & $\\dots$ \\\\\n",
"\t10 & Falkland Islands (Malvinas) & United Kingdom & -51.7963 & -59.5236 & 0 & $\\dots$ \\\\\n",
"\t11 & Gibraltar & United Kingdom & 36.1408 & -5.3536 & 0 & $\\dots$ \\\\\n",
"\t12 & Isle of Man & United Kingdom & 54.2361 & -4.5481 & 0 & $\\dots$ \\\\\n",
"\t13 & Montserrat & United Kingdom & 16.7425 & -62.1874 & 0 & $\\dots$ \\\\\n",
"\t14 & Turks and Caicos Islands & United Kingdom & 21.694 & -71.7979 & 0 & $\\dots$ \\\\\n",
"\t15 & \\emph{missing} & United Kingdom & 55.3781 & -3.436 & 0 & $\\dots$ \\\\\n",
"\t16 & \\emph{missing} & Uruguay & -32.5228 & -55.7658 & 0 & $\\dots$ \\\\\n",
"\t17 & \\emph{missing} & Uzbekistan & 41.3775 & 64.5853 & 0 & $\\dots$ \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"\u001b[1m17×347 DataFrame\u001b[0m\n",
"\u001b[1m Row \u001b[0m│\u001b[1m province \u001b[0m\u001b[1m country \u001b[0m\u001b[1m Lat \u001b[0m\u001b[1m Long \u001b[0m ⋯\n",
"\u001b[1m \u001b[0m│\u001b[90m String? \u001b[0m\u001b[90m String \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m Float64? \u001b[0m ⋯\n",
"─────┼──────────────────────────────────────────────────────────────────────────\n",
" 1 │\u001b[90m missing \u001b[0m US 40.0 -100.0 ⋯\n",
" 2 │\u001b[90m missing \u001b[0m Uganda 1.37333 32.2903\n",
" 3 │\u001b[90m missing \u001b[0m Ukraine 48.3794 31.1656\n",
" 4 │\u001b[90m missing \u001b[0m United Arab Emirates 23.4241 53.8478\n",
" 5 │ Anguilla United Kingdom 18.2206 -63.0686 ⋯\n",
" 6 │ Bermuda United Kingdom 32.3078 -64.7505\n",
" 7 │ British Virgin Islands United Kingdom 18.4207 -64.64\n",
" 8 │ Cayman Islands United Kingdom 19.3133 -81.2546\n",
" 9 │ Channel Islands United Kingdom 49.3723 -2.3644 ⋯\n",
" 10 │ Falkland Islands (Malvinas) United Kingdom -51.7963 -59.5236\n",
" 11 │ Gibraltar United Kingdom 36.1408 -5.3536\n",
" 12 │ Isle of Man United Kingdom 54.2361 -4.5481\n",
" 13 │ Montserrat United Kingdom 16.7425 -62.1874 ⋯\n",
" 14 │ Turks and Caicos Islands United Kingdom 21.694 -71.7979\n",
" 15 │\u001b[90m missing \u001b[0m United Kingdom 55.3781 -3.436\n",
" 16 │\u001b[90m missing \u001b[0m Uruguay -32.5228 -55.7658\n",
" 17 │\u001b[90m missing \u001b[0m Uzbekistan 41.3775 64.5853 ⋯\n",
"\u001b[31m 343 columns omitted\u001b[0m"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data[U_countries, :]"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"271-element BitArray{1}:\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" ⋮\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# . is \"broadcasting\": apply operation to each element of a vector\n",
"countries .== \"US\" "
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"248"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"US_row = findfirst(countries .== \"US\")"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"DataFrameRow (347 columns)
province country Lat Long 1/22/20 1/23/20 1/24/20 1/25/20 1/26/20 String? String Float64? Float64? Int64 Int64 Int64 Int64 Int64 248 missing US 40.0 -100.0 1 1 2 2 5
"
],
"text/latex": [
"\\begin{tabular}{r|cccccccccc}\n",
"\t& province & country & Lat & Long & 1/22/20 & 1/23/20 & 1/24/20 & 1/25/20 & 1/26/20 & \\\\\n",
"\t\\hline\n",
"\t& String? & String & Float64? & Float64? & Int64 & Int64 & Int64 & Int64 & Int64 & \\\\\n",
"\t\\hline\n",
"\t248 & \\emph{missing} & US & 40.0 & -100.0 & 1 & 1 & 2 & 2 & 5 & $\\dots$ \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"\u001b[1mDataFrameRow\u001b[0m\n",
"\u001b[1m Row \u001b[0m│\u001b[1m province \u001b[0m\u001b[1m country \u001b[0m\u001b[1m Lat \u001b[0m\u001b[1m Long \u001b[0m\u001b[1m 1/22/20 \u001b[0m\u001b[1m 1/23/20 \u001b[0m\u001b[1m 1/24/20 \u001b[0m\u001b[1m 1/25/\u001b[0m ⋯\n",
"\u001b[1m \u001b[0m│\u001b[90m String? \u001b[0m\u001b[90m String \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64\u001b[0m ⋯\n",
"─────┼──────────────────────────────────────────────────────────────────────────\n",
" 248 │\u001b[90m missing \u001b[0m US 40.0 -100.0 1 1 2 ⋯\n",
"\u001b[31m 340 columns omitted\u001b[0m"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data[US_row, :]"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"DataFrameRow (347 columns)
province country Lat Long 1/22/20 1/23/20 1/24/20 1/25/20 1/26/20 String? String Float64? Float64? Int64 Int64 Int64 Int64 Int64 248 missing US 40.0 -100.0 1 1 2 2 5
"
],
"text/latex": [
"\\begin{tabular}{r|cccccccccc}\n",
"\t& province & country & Lat & Long & 1/22/20 & 1/23/20 & 1/24/20 & 1/25/20 & 1/26/20 & \\\\\n",
"\t\\hline\n",
"\t& String? & String & Float64? & Float64? & Int64 & Int64 & Int64 & Int64 & Int64 & \\\\\n",
"\t\\hline\n",
"\t248 & \\emph{missing} & US & 40.0 & -100.0 & 1 & 1 & 2 & 2 & 5 & $\\dots$ \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"\u001b[1mDataFrameRow\u001b[0m\n",
"\u001b[1m Row \u001b[0m│\u001b[1m province \u001b[0m\u001b[1m country \u001b[0m\u001b[1m Lat \u001b[0m\u001b[1m Long \u001b[0m\u001b[1m 1/22/20 \u001b[0m\u001b[1m 1/23/20 \u001b[0m\u001b[1m 1/24/20 \u001b[0m\u001b[1m 1/25/\u001b[0m ⋯\n",
"\u001b[1m \u001b[0m│\u001b[90m String? \u001b[0m\u001b[90m String \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64\u001b[0m ⋯\n",
"─────┼──────────────────────────────────────────────────────────────────────────\n",
" 248 │\u001b[90m missing \u001b[0m US 40.0 -100.0 1 1 2 ⋯\n",
"\u001b[31m 340 columns omitted\u001b[0m"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"UC_data_row = data[US_row, :]"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"343-element Array{Int64,1}:\n",
" 1\n",
" 1\n",
" 2\n",
" 2\n",
" 5\n",
" 5\n",
" 5\n",
" 6\n",
" 6\n",
" 8\n",
" 8\n",
" 8\n",
" 11\n",
" ⋮\n",
" 17468841\n",
" 17665284\n",
" 17853731\n",
" 18045048\n",
" 18239758\n",
" 18466484\n",
" 18665343\n",
" 18765529\n",
" 18992126\n",
" 19142603\n",
" 19309281\n",
" 19510836"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"US_data = convert(Vector, UC_data_row[5:end])"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m\u001b[1m Resolving\u001b[22m\u001b[39m package versions...\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m libfdk_aac_jll ── v0.1.6+4\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m EarCut_jll ────── v2.1.5+1\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m x265_jll ──────── v3.0.0+3\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m Showoff ───────── v0.3.2\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m RecipesPipeline ─ v0.1.13\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m Contour ───────── v0.5.7\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m StaticArrays ──── v1.0.1\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m Plots ─────────── v1.6.12\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m FreeType2_jll ─── v2.10.1+5\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m Bzip2_jll ─────── v1.0.6+5\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m LAME_jll ──────── v3.100.0+3\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m OpenSSL_jll ───── v1.1.1+6\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m Grisu ─────────── v1.0.0\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m libass_jll ────── v0.14.0+4\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m libvorbis_jll ─── v1.3.6+6\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m LaTeXStrings ──── v1.2.0\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m IterTools ─────── v1.3.0\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m Opus_jll ──────── v1.3.1+3\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m Adapt ─────────── v2.3.0\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m LibVPX_jll ────── v1.9.0+1\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m GeometryTypes ─── v0.8.4\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m FFMPEG_jll ────── v4.3.1+4\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m PlotUtils ─────── v1.0.8\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m FFMPEG ────────── v0.4.0\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m Ogg_jll ───────── v1.3.4+2\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m RecipesBase ───── v1.1.1\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m Zlib_jll ──────── v1.2.11+18\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m GR ────────────── v0.49.1\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m Latexify ──────── v0.14.7\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m GeometryBasics ── v0.3.5\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m StatsBase ─────── v0.33.2\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m NaNMath ───────── v0.3.5\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m x264_jll ──────── v2020.7.14+2\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m FriBidi_jll ───── v1.0.5+6\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m PlotThemes ────── v2.0.0\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m StructArrays ──── v0.4.4\n",
"\u001b[32m\u001b[1m Installed\u001b[22m\u001b[39m ColorSchemes ──── v3.10.2\n",
"\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `C:\\Users\\kcsgo\\.julia\\environments\\v1.4\\Project.toml`\n",
" \u001b[90m [91a5bcdd]\u001b[39m\u001b[92m + Plots v1.6.12\u001b[39m\n",
"\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `C:\\Users\\kcsgo\\.julia\\environments\\v1.4\\Manifest.toml`\n",
" \u001b[90m [79e6a3ab]\u001b[39m\u001b[92m + Adapt v2.3.0\u001b[39m\n",
" \u001b[90m [6e34b625]\u001b[39m\u001b[92m + Bzip2_jll v1.0.6+5\u001b[39m\n",
" \u001b[90m [35d6a980]\u001b[39m\u001b[92m + ColorSchemes v3.10.2\u001b[39m\n",
" \u001b[90m [d38c429a]\u001b[39m\u001b[92m + Contour v0.5.7\u001b[39m\n",
" \u001b[90m [5ae413db]\u001b[39m\u001b[92m + EarCut_jll v2.1.5+1\u001b[39m\n",
" \u001b[90m [c87230d0]\u001b[39m\u001b[92m + FFMPEG v0.4.0\u001b[39m\n",
" \u001b[90m [b22a6f82]\u001b[39m\u001b[92m + FFMPEG_jll v4.3.1+4\u001b[39m\n",
" \u001b[90m [d7e528f0]\u001b[39m\u001b[92m + FreeType2_jll v2.10.1+5\u001b[39m\n",
" \u001b[90m [559328eb]\u001b[39m\u001b[92m + FriBidi_jll v1.0.5+6\u001b[39m\n",
" \u001b[90m [28b8d3ca]\u001b[39m\u001b[92m + GR v0.49.1\u001b[39m\n",
" \u001b[90m [5c1252a2]\u001b[39m\u001b[92m + GeometryBasics v0.3.5\u001b[39m\n",
" \u001b[90m [4d00f742]\u001b[39m\u001b[92m + GeometryTypes v0.8.4\u001b[39m\n",
" \u001b[90m [42e2da0e]\u001b[39m\u001b[92m + Grisu v1.0.0\u001b[39m\n",
" \u001b[90m [c8e1da08]\u001b[39m\u001b[92m + IterTools v1.3.0\u001b[39m\n",
" \u001b[90m [c1c5ebd0]\u001b[39m\u001b[92m + LAME_jll v3.100.0+3\u001b[39m\n",
" \u001b[90m [b964fa9f]\u001b[39m\u001b[92m + LaTeXStrings v1.2.0\u001b[39m\n",
" \u001b[90m [23fbe1c1]\u001b[39m\u001b[92m + Latexify v0.14.7\u001b[39m\n",
" \u001b[90m [dd192d2f]\u001b[39m\u001b[92m + LibVPX_jll v1.9.0+1\u001b[39m\n",
" \u001b[90m [77ba4419]\u001b[39m\u001b[92m + NaNMath v0.3.5\u001b[39m\n",
" \u001b[90m [e7412a2a]\u001b[39m\u001b[92m + Ogg_jll v1.3.4+2\u001b[39m\n",
" \u001b[90m [458c3c95]\u001b[39m\u001b[92m + OpenSSL_jll v1.1.1+6\u001b[39m\n",
" \u001b[90m [91d4177d]\u001b[39m\u001b[92m + Opus_jll v1.3.1+3\u001b[39m\n",
" \u001b[90m [ccf2f8ad]\u001b[39m\u001b[92m + PlotThemes v2.0.0\u001b[39m\n",
" \u001b[90m [995b91a9]\u001b[39m\u001b[92m + PlotUtils v1.0.8\u001b[39m\n",
" \u001b[90m [91a5bcdd]\u001b[39m\u001b[92m + Plots v1.6.12\u001b[39m\n",
" \u001b[90m [3cdcf5f2]\u001b[39m\u001b[92m + RecipesBase v1.1.1\u001b[39m\n",
" \u001b[90m [01d81517]\u001b[39m\u001b[92m + RecipesPipeline v0.1.13\u001b[39m\n",
" \u001b[90m [992d4aef]\u001b[39m\u001b[92m + Showoff v0.3.2\u001b[39m\n",
" \u001b[90m [90137ffa]\u001b[39m\u001b[92m + StaticArrays v1.0.1\u001b[39m\n",
" \u001b[90m [2913bbd2]\u001b[39m\u001b[92m + StatsBase v0.33.2\u001b[39m\n",
" \u001b[90m [09ab397b]\u001b[39m\u001b[92m + StructArrays v0.4.4\u001b[39m\n",
" \u001b[90m [83775a58]\u001b[39m\u001b[92m + Zlib_jll v1.2.11+18\u001b[39m\n",
" \u001b[90m [0ac62f75]\u001b[39m\u001b[92m + libass_jll v0.14.0+4\u001b[39m\n",
" \u001b[90m [f638f0a6]\u001b[39m\u001b[92m + libfdk_aac_jll v0.1.6+4\u001b[39m\n",
" \u001b[90m [f27f6e37]\u001b[39m\u001b[92m + libvorbis_jll v1.3.6+6\u001b[39m\n",
" \u001b[90m [1270edf5]\u001b[39m\u001b[92m + x264_jll v2020.7.14+2\u001b[39m\n",
" \u001b[90m [dfaa095f]\u001b[39m\u001b[92m + x265_jll v3.0.0+3\u001b[39m\n",
"\u001b[32m\u001b[1m Building\u001b[22m\u001b[39m GR → `C:\\Users\\kcsgo\\.julia\\packages\\GR\\cRdXQ\\deps\\build.log`\n"
]
}
],
"source": [
"Pkg.add(\"Plots\")"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"┌ Info: Precompiling Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80]\n",
"└ @ Base loading.jl:1260\n"
]
}
],
"source": [
"using Plots"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
" \n",
" \n",
" \n"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(US_data)"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"347-element Array{String,1}:\n",
" \"province\"\n",
" \"country\"\n",
" \"Lat\"\n",
" \"Long\"\n",
" \"1/22/20\"\n",
" \"1/23/20\"\n",
" \"1/24/20\"\n",
" \"1/25/20\"\n",
" \"1/26/20\"\n",
" \"1/27/20\"\n",
" \"1/28/20\"\n",
" \"1/29/20\"\n",
" \"1/30/20\"\n",
" ⋮\n",
" \"12/18/20\"\n",
" \"12/19/20\"\n",
" \"12/20/20\"\n",
" \"12/21/20\"\n",
" \"12/22/20\"\n",
" \"12/23/20\"\n",
" \"12/24/20\"\n",
" \"12/25/20\"\n",
" \"12/26/20\"\n",
" \"12/27/20\"\n",
" \"12/28/20\"\n",
" \"12/29/20\""
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"col_names = names(data)"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"343-element Array{String,1}:\n",
" \"1/22/20\"\n",
" \"1/23/20\"\n",
" \"1/24/20\"\n",
" \"1/25/20\"\n",
" \"1/26/20\"\n",
" \"1/27/20\"\n",
" \"1/28/20\"\n",
" \"1/29/20\"\n",
" \"1/30/20\"\n",
" \"1/31/20\"\n",
" \"2/1/20\"\n",
" \"2/2/20\"\n",
" \"2/3/20\"\n",
" ⋮\n",
" \"12/18/20\"\n",
" \"12/19/20\"\n",
" \"12/20/20\"\n",
" \"12/21/20\"\n",
" \"12/22/20\"\n",
" \"12/23/20\"\n",
" \"12/24/20\"\n",
" \"12/25/20\"\n",
" \"12/26/20\"\n",
" \"12/27/20\"\n",
" \"12/28/20\"\n",
" \"12/29/20\""
]
},
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"date_strings = String.(names(data))[5:end]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Parse: convert string representation into a Julia object"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"1/22/20\""
]
},
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"date_strings[1]"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {},
"outputs": [],
"source": [
"using Dates"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dateformat\"d/m/Y\""
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"format = Dates.DateFormat(\"d/m/Y\")"
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {},
"outputs": [
{
"ename": "ArgumentError",
"evalue": "ArgumentError: Month: 22 out of range (1:12)",
"output_type": "error",
"traceback": [
"ArgumentError: Month: 22 out of range (1:12)",
"",
"Stacktrace:",
" [1] Date(::Int64, ::Int64, ::Int64) at D:\\buildbot\\worker\\package_win64\\build\\usr\\share\\julia\\stdlib\\v1.4\\Dates\\src\\types.jl:223",
" [2] parse(::Type{Date}, ::String, ::DateFormat{Symbol(\"d/m/Y\"),Tuple{Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'m'},Dates.Delim{Char,1},Dates.DatePart{'Y'}}}) at D:\\buildbot\\worker\\package_win64\\build\\usr\\share\\julia\\stdlib\\v1.4\\Dates\\src\\parse.jl:285",
" [3] top-level scope at In[60]:1"
]
}
],
"source": [
"parse(Date, date_strings[1], format)"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2020-01-22"
]
},
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"format = Dates.DateFormat(\"m/d/Y\")\n",
"parse(Date, date_strings[1], format) + Year(2000)"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"343-element Array{Date,1}:\n",
" 2020-01-22\n",
" 2020-01-23\n",
" 2020-01-24\n",
" 2020-01-25\n",
" 2020-01-26\n",
" 2020-01-27\n",
" 2020-01-28\n",
" 2020-01-29\n",
" 2020-01-30\n",
" 2020-01-31\n",
" 2020-02-01\n",
" 2020-02-02\n",
" 2020-02-03\n",
" ⋮\n",
" 2020-12-18\n",
" 2020-12-19\n",
" 2020-12-20\n",
" 2020-12-21\n",
" 2020-12-22\n",
" 2020-12-23\n",
" 2020-12-24\n",
" 2020-12-25\n",
" 2020-12-26\n",
" 2020-12-27\n",
" 2020-12-28\n",
" 2020-12-29"
]
},
"execution_count": 63,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dates = parse.(Date, date_strings, format) + Year(2000)"
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"