{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exploring data on COVID-19"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this notebook we will explore and analyse some data on the advance of the COVID-19 pandemic. The goal is to produce a plot like this:\n",
"\n",
"![plot](US_data.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Shift-enter to evaluate a cell\n",
"\n",
"$y = x^2$"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"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": [
"3"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = 3"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Int64"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"typeof(x)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"9"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x * x"
]
},
{
"cell_type": "code",
"execution_count": 7,
"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.csvhttps://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv\""
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"url * url"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"* (generic function with 357 methods)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"*"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"methods(*); # remove `;` to see the output"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1 + 7im"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(1 + 2im) * (3 + im)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"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": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"@which (1 + 2im) * (3 + im)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"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": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"url"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Grab the data"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"covid_data.csv\""
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"download(url, \"covid_data.csv\")"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"readdir (generic function with 2 methods)"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"readdir"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3-element Array{String,1}:\n",
" \".ipynb_checkpoints\"\n",
" \"01 - Exploring COVID-19 data.ipynb\"\n",
" \"covid_data.csv\""
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"readdir()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Install a package *ONCE* in our current Julia installation:"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m registry at `~/.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[36m\u001b[1mFetching:\u001b[22m\u001b[39m [> ] 0.0 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 0.4 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 0.9 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 1.3 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 1.8 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 2.2 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 2.7 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 3.1 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 3.6 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 4.0 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 4.5 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 4.9 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 5.4 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 5.8 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 6.3 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 6.7 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 7.2 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 7.6 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 8.1 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 8.5 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 9.0 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 9.4 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 9.9 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 10.3 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 10.8 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 11.2 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 11.7 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 12.1 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 12.6 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 13.0 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 13.5 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 13.9 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 14.3 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 14.8 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 15.2 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 15.7 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 16.1 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 16.6 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 17.0 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 17.5 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 17.9 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 18.4 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 18.8 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 19.3 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 19.7 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 20.2 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 20.6 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 21.1 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 21.5 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 22.0 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 22.4 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 22.9 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 23.3 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 23.8 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 24.2 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 24.7 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 25.1 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 25.6 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 26.0 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 26.5 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 26.9 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 27.4 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 27.8 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 28.3 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 28.7 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 29.1 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 29.6 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 30.0 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 30.5 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 30.9 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 31.4 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 31.8 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 32.3 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 32.7 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 33.2 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 33.6 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 34.1 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 34.5 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 35.0 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 35.4 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 35.9 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 36.3 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 36.8 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 37.2 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 37.7 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 38.1 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 38.6 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 39.0 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 39.5 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 39.9 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 40.4 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 40.8 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 41.3 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 41.7 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 42.2 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 42.6 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 43.0 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 43.5 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 43.9 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 44.4 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 44.8 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 45.3 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 45.7 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 46.2 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 46.6 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 47.1 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 47.5 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 48.0 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 48.4 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 48.9 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 49.3 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 49.8 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 50.2 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 50.7 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 51.1 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 51.6 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 52.0 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 52.5 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 52.9 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 53.4 %\r",
" \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] "
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[2K\u001b[?25h[1mFetching:\u001b[22m\u001b[39m [========================================>] 100.0 %"
]
},
{
"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 OpenSSL_jll ─ v1.1.1+2\n",
"######################################################################### 100.0%##O#- # \n",
"\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `~/.julia/environments/v1.4/Project.toml`\n",
"\u001b[90m [no changes]\u001b[39m\n",
"\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `~/.julia/environments/v1.4/Manifest.toml`\n",
" \u001b[90m [458c3c95]\u001b[39m\u001b[93m ↑ OpenSSL_jll v1.1.1+1 ⇒ v1.1.1+2\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": "markdown",
"metadata": {},
"source": [
"Load a package every time we run a Julia session: "
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"using CSV # Comma Separated Values"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
Province/State Country/Region Lat Long 1/22/20 String⍰ String Float64 Float64 Int64 253 rows × 72 columns (omitted printing of 67 columns)
1 missing Afghanistan 33.0 65.0 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 -28.0167 153.4 0 13 South Australia Australia -34.9285 138.601 0 14 Tasmania Australia -41.4545 145.971 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.0343 -77.3963 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.0 0 25 missing Benin 9.3077 2.3158 0 26 missing Bhutan 27.5142 90.4336 0 27 missing Bolivia -16.2902 -63.5887 0 28 missing Bosnia and Herzegovina 43.9159 17.6791 0 29 missing Brazil -14.235 -51.9253 0 30 missing Brunei 4.5353 114.728 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 & & Afghanistan & 33.0 & 65.0 & 0 & $\\dots$ \\\\\n",
"\t2 & & Albania & 41.1533 & 20.1683 & 0 & $\\dots$ \\\\\n",
"\t3 & & Algeria & 28.0339 & 1.6596 & 0 & $\\dots$ \\\\\n",
"\t4 & & Andorra & 42.5063 & 1.5218 & 0 & $\\dots$ \\\\\n",
"\t5 & & Angola & -11.2027 & 17.8739 & 0 & $\\dots$ \\\\\n",
"\t6 & & Antigua and Barbuda & 17.0608 & -61.7964 & 0 & $\\dots$ \\\\\n",
"\t7 & & Argentina & -38.4161 & -63.6167 & 0 & $\\dots$ \\\\\n",
"\t8 & & 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 & -28.0167 & 153.4 & 0 & $\\dots$ \\\\\n",
"\t13 & South Australia & Australia & -34.9285 & 138.601 & 0 & $\\dots$ \\\\\n",
"\t14 & Tasmania & Australia & -41.4545 & 145.971 & 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 & & Austria & 47.5162 & 14.5501 & 0 & $\\dots$ \\\\\n",
"\t18 & & Azerbaijan & 40.1431 & 47.5769 & 0 & $\\dots$ \\\\\n",
"\t19 & & Bahamas & 25.0343 & -77.3963 & 0 & $\\dots$ \\\\\n",
"\t20 & & Bahrain & 26.0275 & 50.55 & 0 & $\\dots$ \\\\\n",
"\t21 & & Bangladesh & 23.685 & 90.3563 & 0 & $\\dots$ \\\\\n",
"\t22 & & Barbados & 13.1939 & -59.5432 & 0 & $\\dots$ \\\\\n",
"\t23 & & Belarus & 53.7098 & 27.9534 & 0 & $\\dots$ \\\\\n",
"\t24 & & Belgium & 50.8333 & 4.0 & 0 & $\\dots$ \\\\\n",
"\t25 & & Benin & 9.3077 & 2.3158 & 0 & $\\dots$ \\\\\n",
"\t26 & & Bhutan & 27.5142 & 90.4336 & 0 & $\\dots$ \\\\\n",
"\t27 & & Bolivia & -16.2902 & -63.5887 & 0 & $\\dots$ \\\\\n",
"\t28 & & Bosnia and Herzegovina & 43.9159 & 17.6791 & 0 & $\\dots$ \\\\\n",
"\t29 & & Brazil & -14.235 & -51.9253 & 0 & $\\dots$ \\\\\n",
"\t30 & & Brunei & 4.5353 & 114.728 & 0 & $\\dots$ \\\\\n",
"\t$\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"253×72 DataFrames.DataFrame. Omitted printing of 69 columns\n",
"│ Row │ Province/State │ Country/Region │ Lat │\n",
"│ │ \u001b[90mUnion{Missing, String}\u001b[39m │ \u001b[90mString\u001b[39m │ \u001b[90mFloat64\u001b[39m │\n",
"├─────┼──────────────────────────────┼───────────────────────┼──────────┤\n",
"│ 1 │ \u001b[90mmissing\u001b[39m │ Afghanistan │ 33.0 │\n",
"│ 2 │ \u001b[90mmissing\u001b[39m │ Albania │ 41.1533 │\n",
"│ 3 │ \u001b[90mmissing\u001b[39m │ Algeria │ 28.0339 │\n",
"│ 4 │ \u001b[90mmissing\u001b[39m │ Andorra │ 42.5063 │\n",
"│ 5 │ \u001b[90mmissing\u001b[39m │ Angola │ -11.2027 │\n",
"│ 6 │ \u001b[90mmissing\u001b[39m │ Antigua and Barbuda │ 17.0608 │\n",
"│ 7 │ \u001b[90mmissing\u001b[39m │ Argentina │ -38.4161 │\n",
"│ 8 │ \u001b[90mmissing\u001b[39m │ Armenia │ 40.0691 │\n",
"│ 9 │ Australian Capital Territory │ Australia │ -35.4735 │\n",
"│ 10 │ New South Wales │ Australia │ -33.8688 │\n",
"⋮\n",
"│ 243 │ \u001b[90mmissing\u001b[39m │ Guinea-Bissau │ 11.8037 │\n",
"│ 244 │ \u001b[90mmissing\u001b[39m │ Mali │ 17.5707 │\n",
"│ 245 │ \u001b[90mmissing\u001b[39m │ Saint Kitts and Nevis │ 17.3578 │\n",
"│ 246 │ Northwest Territories │ Canada │ 64.8255 │\n",
"│ 247 │ Yukon │ Canada │ 64.2823 │\n",
"│ 248 │ \u001b[90mmissing\u001b[39m │ Kosovo │ 42.6026 │\n",
"│ 249 │ \u001b[90mmissing\u001b[39m │ Burma │ 21.9162 │\n",
"│ 250 │ Anguilla │ United Kingdom │ 18.2206 │\n",
"│ 251 │ British Virgin Islands │ United Kingdom │ 18.4207 │\n",
"│ 252 │ Turks and Caicos Islands │ United Kingdom │ 21.694 │\n",
"│ 253 │ \u001b[90mmissing\u001b[39m │ MS Zaandam │ 0.0 │"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"CSV.read(\"covid_data.csv\") # run the function `read` from the package CSV"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"data = CSV.read(\"covid_data.csv\"); "
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"Province/State Country/Region Lat Long 1/22/20 String⍰ String Float64 Float64 Int64 253 rows × 72 columns (omitted printing of 67 columns)
1 missing Afghanistan 33.0 65.0 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 -28.0167 153.4 0 13 South Australia Australia -34.9285 138.601 0 14 Tasmania Australia -41.4545 145.971 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.0343 -77.3963 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.0 0 25 missing Benin 9.3077 2.3158 0 26 missing Bhutan 27.5142 90.4336 0 27 missing Bolivia -16.2902 -63.5887 0 28 missing Bosnia and Herzegovina 43.9159 17.6791 0 29 missing Brazil -14.235 -51.9253 0 30 missing Brunei 4.5353 114.728 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 & & Afghanistan & 33.0 & 65.0 & 0 & $\\dots$ \\\\\n",
"\t2 & & Albania & 41.1533 & 20.1683 & 0 & $\\dots$ \\\\\n",
"\t3 & & Algeria & 28.0339 & 1.6596 & 0 & $\\dots$ \\\\\n",
"\t4 & & Andorra & 42.5063 & 1.5218 & 0 & $\\dots$ \\\\\n",
"\t5 & & Angola & -11.2027 & 17.8739 & 0 & $\\dots$ \\\\\n",
"\t6 & & Antigua and Barbuda & 17.0608 & -61.7964 & 0 & $\\dots$ \\\\\n",
"\t7 & & Argentina & -38.4161 & -63.6167 & 0 & $\\dots$ \\\\\n",
"\t8 & & 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 & -28.0167 & 153.4 & 0 & $\\dots$ \\\\\n",
"\t13 & South Australia & Australia & -34.9285 & 138.601 & 0 & $\\dots$ \\\\\n",
"\t14 & Tasmania & Australia & -41.4545 & 145.971 & 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 & & Austria & 47.5162 & 14.5501 & 0 & $\\dots$ \\\\\n",
"\t18 & & Azerbaijan & 40.1431 & 47.5769 & 0 & $\\dots$ \\\\\n",
"\t19 & & Bahamas & 25.0343 & -77.3963 & 0 & $\\dots$ \\\\\n",
"\t20 & & Bahrain & 26.0275 & 50.55 & 0 & $\\dots$ \\\\\n",
"\t21 & & Bangladesh & 23.685 & 90.3563 & 0 & $\\dots$ \\\\\n",
"\t22 & & Barbados & 13.1939 & -59.5432 & 0 & $\\dots$ \\\\\n",
"\t23 & & Belarus & 53.7098 & 27.9534 & 0 & $\\dots$ \\\\\n",
"\t24 & & Belgium & 50.8333 & 4.0 & 0 & $\\dots$ \\\\\n",
"\t25 & & Benin & 9.3077 & 2.3158 & 0 & $\\dots$ \\\\\n",
"\t26 & & Bhutan & 27.5142 & 90.4336 & 0 & $\\dots$ \\\\\n",
"\t27 & & Bolivia & -16.2902 & -63.5887 & 0 & $\\dots$ \\\\\n",
"\t28 & & Bosnia and Herzegovina & 43.9159 & 17.6791 & 0 & $\\dots$ \\\\\n",
"\t29 & & Brazil & -14.235 & -51.9253 & 0 & $\\dots$ \\\\\n",
"\t30 & & Brunei & 4.5353 & 114.728 & 0 & $\\dots$ \\\\\n",
"\t$\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"253×72 DataFrames.DataFrame. Omitted printing of 69 columns\n",
"│ Row │ Province/State │ Country/Region │ Lat │\n",
"│ │ \u001b[90mUnion{Missing, String}\u001b[39m │ \u001b[90mString\u001b[39m │ \u001b[90mFloat64\u001b[39m │\n",
"├─────┼──────────────────────────────┼───────────────────────┼──────────┤\n",
"│ 1 │ \u001b[90mmissing\u001b[39m │ Afghanistan │ 33.0 │\n",
"│ 2 │ \u001b[90mmissing\u001b[39m │ Albania │ 41.1533 │\n",
"│ 3 │ \u001b[90mmissing\u001b[39m │ Algeria │ 28.0339 │\n",
"│ 4 │ \u001b[90mmissing\u001b[39m │ Andorra │ 42.5063 │\n",
"│ 5 │ \u001b[90mmissing\u001b[39m │ Angola │ -11.2027 │\n",
"│ 6 │ \u001b[90mmissing\u001b[39m │ Antigua and Barbuda │ 17.0608 │\n",
"│ 7 │ \u001b[90mmissing\u001b[39m │ Argentina │ -38.4161 │\n",
"│ 8 │ \u001b[90mmissing\u001b[39m │ Armenia │ 40.0691 │\n",
"│ 9 │ Australian Capital Territory │ Australia │ -35.4735 │\n",
"│ 10 │ New South Wales │ Australia │ -33.8688 │\n",
"⋮\n",
"│ 243 │ \u001b[90mmissing\u001b[39m │ Guinea-Bissau │ 11.8037 │\n",
"│ 244 │ \u001b[90mmissing\u001b[39m │ Mali │ 17.5707 │\n",
"│ 245 │ \u001b[90mmissing\u001b[39m │ Saint Kitts and Nevis │ 17.3578 │\n",
"│ 246 │ Northwest Territories │ Canada │ 64.8255 │\n",
"│ 247 │ Yukon │ Canada │ 64.2823 │\n",
"│ 248 │ \u001b[90mmissing\u001b[39m │ Kosovo │ 42.6026 │\n",
"│ 249 │ \u001b[90mmissing\u001b[39m │ Burma │ 21.9162 │\n",
"│ 250 │ Anguilla │ United Kingdom │ 18.2206 │\n",
"│ 251 │ British Virgin Islands │ United Kingdom │ 18.4207 │\n",
"│ 252 │ Turks and Caicos Islands │ United Kingdom │ 21.694 │\n",
"│ 253 │ \u001b[90mmissing\u001b[39m │ MS Zaandam │ 0.0 │"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"DataFrames.DataFrame"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"typeof(data)"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
"using DataFrames"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"province country Lat Long 1/22/20 String⍰ String Float64 Float64 Int64 253 rows × 72 columns (omitted printing of 67 columns)
1 missing Afghanistan 33.0 65.0 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 -28.0167 153.4 0 13 South Australia Australia -34.9285 138.601 0 14 Tasmania Australia -41.4545 145.971 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.0343 -77.3963 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.0 0 25 missing Benin 9.3077 2.3158 0 26 missing Bhutan 27.5142 90.4336 0 27 missing Bolivia -16.2902 -63.5887 0 28 missing Bosnia and Herzegovina 43.9159 17.6791 0 29 missing Brazil -14.235 -51.9253 0 30 missing Brunei 4.5353 114.728 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 & & Afghanistan & 33.0 & 65.0 & 0 & $\\dots$ \\\\\n",
"\t2 & & Albania & 41.1533 & 20.1683 & 0 & $\\dots$ \\\\\n",
"\t3 & & Algeria & 28.0339 & 1.6596 & 0 & $\\dots$ \\\\\n",
"\t4 & & Andorra & 42.5063 & 1.5218 & 0 & $\\dots$ \\\\\n",
"\t5 & & Angola & -11.2027 & 17.8739 & 0 & $\\dots$ \\\\\n",
"\t6 & & Antigua and Barbuda & 17.0608 & -61.7964 & 0 & $\\dots$ \\\\\n",
"\t7 & & Argentina & -38.4161 & -63.6167 & 0 & $\\dots$ \\\\\n",
"\t8 & & 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 & -28.0167 & 153.4 & 0 & $\\dots$ \\\\\n",
"\t13 & South Australia & Australia & -34.9285 & 138.601 & 0 & $\\dots$ \\\\\n",
"\t14 & Tasmania & Australia & -41.4545 & 145.971 & 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 & & Austria & 47.5162 & 14.5501 & 0 & $\\dots$ \\\\\n",
"\t18 & & Azerbaijan & 40.1431 & 47.5769 & 0 & $\\dots$ \\\\\n",
"\t19 & & Bahamas & 25.0343 & -77.3963 & 0 & $\\dots$ \\\\\n",
"\t20 & & Bahrain & 26.0275 & 50.55 & 0 & $\\dots$ \\\\\n",
"\t21 & & Bangladesh & 23.685 & 90.3563 & 0 & $\\dots$ \\\\\n",
"\t22 & & Barbados & 13.1939 & -59.5432 & 0 & $\\dots$ \\\\\n",
"\t23 & & Belarus & 53.7098 & 27.9534 & 0 & $\\dots$ \\\\\n",
"\t24 & & Belgium & 50.8333 & 4.0 & 0 & $\\dots$ \\\\\n",
"\t25 & & Benin & 9.3077 & 2.3158 & 0 & $\\dots$ \\\\\n",
"\t26 & & Bhutan & 27.5142 & 90.4336 & 0 & $\\dots$ \\\\\n",
"\t27 & & Bolivia & -16.2902 & -63.5887 & 0 & $\\dots$ \\\\\n",
"\t28 & & Bosnia and Herzegovina & 43.9159 & 17.6791 & 0 & $\\dots$ \\\\\n",
"\t29 & & Brazil & -14.235 & -51.9253 & 0 & $\\dots$ \\\\\n",
"\t30 & & Brunei & 4.5353 & 114.728 & 0 & $\\dots$ \\\\\n",
"\t$\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"253×72 DataFrame. Omitted printing of 69 columns\n",
"│ Row │ province │ country │ Lat │\n",
"│ │ \u001b[90mUnion{Missing, String}\u001b[39m │ \u001b[90mString\u001b[39m │ \u001b[90mFloat64\u001b[39m │\n",
"├─────┼──────────────────────────────┼───────────────────────┼──────────┤\n",
"│ 1 │ \u001b[90mmissing\u001b[39m │ Afghanistan │ 33.0 │\n",
"│ 2 │ \u001b[90mmissing\u001b[39m │ Albania │ 41.1533 │\n",
"│ 3 │ \u001b[90mmissing\u001b[39m │ Algeria │ 28.0339 │\n",
"│ 4 │ \u001b[90mmissing\u001b[39m │ Andorra │ 42.5063 │\n",
"│ 5 │ \u001b[90mmissing\u001b[39m │ Angola │ -11.2027 │\n",
"│ 6 │ \u001b[90mmissing\u001b[39m │ Antigua and Barbuda │ 17.0608 │\n",
"│ 7 │ \u001b[90mmissing\u001b[39m │ Argentina │ -38.4161 │\n",
"│ 8 │ \u001b[90mmissing\u001b[39m │ Armenia │ 40.0691 │\n",
"│ 9 │ Australian Capital Territory │ Australia │ -35.4735 │\n",
"│ 10 │ New South Wales │ Australia │ -33.8688 │\n",
"⋮\n",
"│ 243 │ \u001b[90mmissing\u001b[39m │ Guinea-Bissau │ 11.8037 │\n",
"│ 244 │ \u001b[90mmissing\u001b[39m │ Mali │ 17.5707 │\n",
"│ 245 │ \u001b[90mmissing\u001b[39m │ Saint Kitts and Nevis │ 17.3578 │\n",
"│ 246 │ Northwest Territories │ Canada │ 64.8255 │\n",
"│ 247 │ Yukon │ Canada │ 64.2823 │\n",
"│ 248 │ \u001b[90mmissing\u001b[39m │ Kosovo │ 42.6026 │\n",
"│ 249 │ \u001b[90mmissing\u001b[39m │ Burma │ 21.9162 │\n",
"│ 250 │ Anguilla │ United Kingdom │ 18.2206 │\n",
"│ 251 │ British Virgin Islands │ United Kingdom │ 18.4207 │\n",
"│ 252 │ Turks and Caicos Islands │ United Kingdom │ 21.694 │\n",
"│ 253 │ \u001b[90mmissing\u001b[39m │ MS Zaandam │ 0.0 │"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data_2 = rename(data, 1 => \"province\", 2 => \"country\") "
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"province country Lat Long 1/22/20 String⍰ String Float64 Float64 Int64 253 rows × 72 columns (omitted printing of 67 columns)
1 missing Afghanistan 33.0 65.0 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 -28.0167 153.4 0 13 South Australia Australia -34.9285 138.601 0 14 Tasmania Australia -41.4545 145.971 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.0343 -77.3963 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.0 0 25 missing Benin 9.3077 2.3158 0 26 missing Bhutan 27.5142 90.4336 0 27 missing Bolivia -16.2902 -63.5887 0 28 missing Bosnia and Herzegovina 43.9159 17.6791 0 29 missing Brazil -14.235 -51.9253 0 30 missing Brunei 4.5353 114.728 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 & & Afghanistan & 33.0 & 65.0 & 0 & $\\dots$ \\\\\n",
"\t2 & & Albania & 41.1533 & 20.1683 & 0 & $\\dots$ \\\\\n",
"\t3 & & Algeria & 28.0339 & 1.6596 & 0 & $\\dots$ \\\\\n",
"\t4 & & Andorra & 42.5063 & 1.5218 & 0 & $\\dots$ \\\\\n",
"\t5 & & Angola & -11.2027 & 17.8739 & 0 & $\\dots$ \\\\\n",
"\t6 & & Antigua and Barbuda & 17.0608 & -61.7964 & 0 & $\\dots$ \\\\\n",
"\t7 & & Argentina & -38.4161 & -63.6167 & 0 & $\\dots$ \\\\\n",
"\t8 & & 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 & -28.0167 & 153.4 & 0 & $\\dots$ \\\\\n",
"\t13 & South Australia & Australia & -34.9285 & 138.601 & 0 & $\\dots$ \\\\\n",
"\t14 & Tasmania & Australia & -41.4545 & 145.971 & 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 & & Austria & 47.5162 & 14.5501 & 0 & $\\dots$ \\\\\n",
"\t18 & & Azerbaijan & 40.1431 & 47.5769 & 0 & $\\dots$ \\\\\n",
"\t19 & & Bahamas & 25.0343 & -77.3963 & 0 & $\\dots$ \\\\\n",
"\t20 & & Bahrain & 26.0275 & 50.55 & 0 & $\\dots$ \\\\\n",
"\t21 & & Bangladesh & 23.685 & 90.3563 & 0 & $\\dots$ \\\\\n",
"\t22 & & Barbados & 13.1939 & -59.5432 & 0 & $\\dots$ \\\\\n",
"\t23 & & Belarus & 53.7098 & 27.9534 & 0 & $\\dots$ \\\\\n",
"\t24 & & Belgium & 50.8333 & 4.0 & 0 & $\\dots$ \\\\\n",
"\t25 & & Benin & 9.3077 & 2.3158 & 0 & $\\dots$ \\\\\n",
"\t26 & & Bhutan & 27.5142 & 90.4336 & 0 & $\\dots$ \\\\\n",
"\t27 & & Bolivia & -16.2902 & -63.5887 & 0 & $\\dots$ \\\\\n",
"\t28 & & Bosnia and Herzegovina & 43.9159 & 17.6791 & 0 & $\\dots$ \\\\\n",
"\t29 & & Brazil & -14.235 & -51.9253 & 0 & $\\dots$ \\\\\n",
"\t30 & & Brunei & 4.5353 & 114.728 & 0 & $\\dots$ \\\\\n",
"\t$\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"253×72 DataFrame. Omitted printing of 69 columns\n",
"│ Row │ province │ country │ Lat │\n",
"│ │ \u001b[90mUnion{Missing, String}\u001b[39m │ \u001b[90mString\u001b[39m │ \u001b[90mFloat64\u001b[39m │\n",
"├─────┼──────────────────────────────┼───────────────────────┼──────────┤\n",
"│ 1 │ \u001b[90mmissing\u001b[39m │ Afghanistan │ 33.0 │\n",
"│ 2 │ \u001b[90mmissing\u001b[39m │ Albania │ 41.1533 │\n",
"│ 3 │ \u001b[90mmissing\u001b[39m │ Algeria │ 28.0339 │\n",
"│ 4 │ \u001b[90mmissing\u001b[39m │ Andorra │ 42.5063 │\n",
"│ 5 │ \u001b[90mmissing\u001b[39m │ Angola │ -11.2027 │\n",
"│ 6 │ \u001b[90mmissing\u001b[39m │ Antigua and Barbuda │ 17.0608 │\n",
"│ 7 │ \u001b[90mmissing\u001b[39m │ Argentina │ -38.4161 │\n",
"│ 8 │ \u001b[90mmissing\u001b[39m │ Armenia │ 40.0691 │\n",
"│ 9 │ Australian Capital Territory │ Australia │ -35.4735 │\n",
"│ 10 │ New South Wales │ Australia │ -33.8688 │\n",
"⋮\n",
"│ 243 │ \u001b[90mmissing\u001b[39m │ Guinea-Bissau │ 11.8037 │\n",
"│ 244 │ \u001b[90mmissing\u001b[39m │ Mali │ 17.5707 │\n",
"│ 245 │ \u001b[90mmissing\u001b[39m │ Saint Kitts and Nevis │ 17.3578 │\n",
"│ 246 │ Northwest Territories │ Canada │ 64.8255 │\n",
"│ 247 │ Yukon │ Canada │ 64.2823 │\n",
"│ 248 │ \u001b[90mmissing\u001b[39m │ Kosovo │ 42.6026 │\n",
"│ 249 │ \u001b[90mmissing\u001b[39m │ Burma │ 21.9162 │\n",
"│ 250 │ Anguilla │ United Kingdom │ 18.2206 │\n",
"│ 251 │ British Virgin Islands │ United Kingdom │ 18.4207 │\n",
"│ 252 │ Turks and Caicos Islands │ United Kingdom │ 21.694 │\n",
"│ 253 │ \u001b[90mmissing\u001b[39m │ MS Zaandam │ 0.0 │"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rename!(data, 1 => \"province\", 2 => \"country\") # ! is convention: function *modifies* its argument in place"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"province country Lat Long 1/22/20 String⍰ String Float64 Float64 Int64 253 rows × 72 columns (omitted printing of 67 columns)
1 missing Afghanistan 33.0 65.0 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 -28.0167 153.4 0 13 South Australia Australia -34.9285 138.601 0 14 Tasmania Australia -41.4545 145.971 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.0343 -77.3963 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.0 0 25 missing Benin 9.3077 2.3158 0 26 missing Bhutan 27.5142 90.4336 0 27 missing Bolivia -16.2902 -63.5887 0 28 missing Bosnia and Herzegovina 43.9159 17.6791 0 29 missing Brazil -14.235 -51.9253 0 30 missing Brunei 4.5353 114.728 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 & & Afghanistan & 33.0 & 65.0 & 0 & $\\dots$ \\\\\n",
"\t2 & & Albania & 41.1533 & 20.1683 & 0 & $\\dots$ \\\\\n",
"\t3 & & Algeria & 28.0339 & 1.6596 & 0 & $\\dots$ \\\\\n",
"\t4 & & Andorra & 42.5063 & 1.5218 & 0 & $\\dots$ \\\\\n",
"\t5 & & Angola & -11.2027 & 17.8739 & 0 & $\\dots$ \\\\\n",
"\t6 & & Antigua and Barbuda & 17.0608 & -61.7964 & 0 & $\\dots$ \\\\\n",
"\t7 & & Argentina & -38.4161 & -63.6167 & 0 & $\\dots$ \\\\\n",
"\t8 & & 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 & -28.0167 & 153.4 & 0 & $\\dots$ \\\\\n",
"\t13 & South Australia & Australia & -34.9285 & 138.601 & 0 & $\\dots$ \\\\\n",
"\t14 & Tasmania & Australia & -41.4545 & 145.971 & 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 & & Austria & 47.5162 & 14.5501 & 0 & $\\dots$ \\\\\n",
"\t18 & & Azerbaijan & 40.1431 & 47.5769 & 0 & $\\dots$ \\\\\n",
"\t19 & & Bahamas & 25.0343 & -77.3963 & 0 & $\\dots$ \\\\\n",
"\t20 & & Bahrain & 26.0275 & 50.55 & 0 & $\\dots$ \\\\\n",
"\t21 & & Bangladesh & 23.685 & 90.3563 & 0 & $\\dots$ \\\\\n",
"\t22 & & Barbados & 13.1939 & -59.5432 & 0 & $\\dots$ \\\\\n",
"\t23 & & Belarus & 53.7098 & 27.9534 & 0 & $\\dots$ \\\\\n",
"\t24 & & Belgium & 50.8333 & 4.0 & 0 & $\\dots$ \\\\\n",
"\t25 & & Benin & 9.3077 & 2.3158 & 0 & $\\dots$ \\\\\n",
"\t26 & & Bhutan & 27.5142 & 90.4336 & 0 & $\\dots$ \\\\\n",
"\t27 & & Bolivia & -16.2902 & -63.5887 & 0 & $\\dots$ \\\\\n",
"\t28 & & Bosnia and Herzegovina & 43.9159 & 17.6791 & 0 & $\\dots$ \\\\\n",
"\t29 & & Brazil & -14.235 & -51.9253 & 0 & $\\dots$ \\\\\n",
"\t30 & & Brunei & 4.5353 & 114.728 & 0 & $\\dots$ \\\\\n",
"\t$\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"253×72 DataFrame. Omitted printing of 69 columns\n",
"│ Row │ province │ country │ Lat │\n",
"│ │ \u001b[90mUnion{Missing, String}\u001b[39m │ \u001b[90mString\u001b[39m │ \u001b[90mFloat64\u001b[39m │\n",
"├─────┼──────────────────────────────┼───────────────────────┼──────────┤\n",
"│ 1 │ \u001b[90mmissing\u001b[39m │ Afghanistan │ 33.0 │\n",
"│ 2 │ \u001b[90mmissing\u001b[39m │ Albania │ 41.1533 │\n",
"│ 3 │ \u001b[90mmissing\u001b[39m │ Algeria │ 28.0339 │\n",
"│ 4 │ \u001b[90mmissing\u001b[39m │ Andorra │ 42.5063 │\n",
"│ 5 │ \u001b[90mmissing\u001b[39m │ Angola │ -11.2027 │\n",
"│ 6 │ \u001b[90mmissing\u001b[39m │ Antigua and Barbuda │ 17.0608 │\n",
"│ 7 │ \u001b[90mmissing\u001b[39m │ Argentina │ -38.4161 │\n",
"│ 8 │ \u001b[90mmissing\u001b[39m │ Armenia │ 40.0691 │\n",
"│ 9 │ Australian Capital Territory │ Australia │ -35.4735 │\n",
"│ 10 │ New South Wales │ Australia │ -33.8688 │\n",
"⋮\n",
"│ 243 │ \u001b[90mmissing\u001b[39m │ Guinea-Bissau │ 11.8037 │\n",
"│ 244 │ \u001b[90mmissing\u001b[39m │ Mali │ 17.5707 │\n",
"│ 245 │ \u001b[90mmissing\u001b[39m │ Saint Kitts and Nevis │ 17.3578 │\n",
"│ 246 │ Northwest Territories │ Canada │ 64.8255 │\n",
"│ 247 │ Yukon │ Canada │ 64.2823 │\n",
"│ 248 │ \u001b[90mmissing\u001b[39m │ Kosovo │ 42.6026 │\n",
"│ 249 │ \u001b[90mmissing\u001b[39m │ Burma │ 21.9162 │\n",
"│ 250 │ Anguilla │ United Kingdom │ 18.2206 │\n",
"│ 251 │ British Virgin Islands │ United Kingdom │ 18.4207 │\n",
"│ 252 │ Turks and Caicos Islands │ United Kingdom │ 21.694 │\n",
"│ 253 │ \u001b[90mmissing\u001b[39m │ MS Zaandam │ 0.0 │"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"DataFrames.rename!(...)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ctrl-M, Y to switch to code cell\n",
"\n",
"Ctrl-M, M to switch to **markdown**\n",
"\n",
"Esc instead of Ctrl-M\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Interact.jl: Simple interactive visualizations"
]
},
{
"cell_type": "code",
"execution_count": 37,
"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": 38,
"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": 40,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"UnitRange{Int64}"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"typeof(1:10)"
]
},
{
"cell_type": "code",
"execution_count": 41,
"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": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"collect(1:10)"
]
},
{
"cell_type": "code",
"execution_count": 42,
"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": 43,
"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": 44,
"metadata": {},
"outputs": [],
"source": [
"for i in 1:10\n",
" i\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.webio.node+json": {
"children": [
{
"children": [
{
"children": [
{
"children": [
{
"children": [
{
"children": [
"i"
],
"instanceArgs": {
"namespace": "html",
"tag": "label"
},
"nodeType": "DOM",
"props": {
"className": "interact ",
"style": {
"padding": "5px 10px 0px 10px"
}
},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "interact-flex-row-left"
},
"type": "node"
},
{
"children": [
{
"children": [],
"instanceArgs": {
"namespace": "html",
"tag": "input"
},
"nodeType": "DOM",
"props": {
"attributes": {
"data-bind": "numericValue: index, valueUpdate: 'input', event: {change: function (){this.changes(this.changes()+1)}}",
"orient": "horizontal",
"type": "range"
},
"className": "slider slider is-fullwidth",
"max": 10,
"min": 1,
"step": 1,
"style": {}
},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "interact-flex-row-center"
},
"type": "node"
},
{
"children": [
{
"children": [],
"instanceArgs": {
"namespace": "html",
"tag": "p"
},
"nodeType": "DOM",
"props": {
"attributes": {
"data-bind": "text: formatted_val"
}
},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "interact-flex-row-right"
},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "interact-flex-row interact-widget"
},
"type": "node"
}
],
"instanceArgs": {
"handlers": {
"changes": [
"(function (val){return (val!=this.model[\"changes\"]()) ? (this.valueFromJulia[\"changes\"]=true, this.model[\"changes\"](val)) : undefined})"
],
"index": [
"(function (val){return (val!=this.model[\"index\"]()) ? (this.valueFromJulia[\"index\"]=true, this.model[\"index\"](val)) : undefined})"
]
},
"id": "10057427426167816433",
"imports": {
"data": [
{
"name": "knockout",
"type": "js",
"url": "/assetserver/800fa077652c804a9c5f68b6c1e29c6c61f85df7-knockout.js"
},
{
"name": "knockout_punches",
"type": "js",
"url": "/assetserver/81e3f253b58efa296c3c65b00e2bf7b25de6cca9-knockout_punches.js"
},
{
"name": null,
"type": "js",
"url": "/assetserver/5d2042c6908ffff0b7c8d26135740476bcf00827-all.js"
},
{
"name": null,
"type": "css",
"url": "/assetserver/87ad319ae61de5d44f67c268a0a8f65862fca478-style.css"
},
{
"name": null,
"type": "css",
"url": "/assetserver/a062b31556f81f574879e47f48c7fae2687f3c82-bulma_confined.min.css"
}
],
"type": "async_block"
},
"mount_callbacks": [
"function () {\n var handler = (function (ko, koPunches) {\n ko.punches.enableAll();\n ko.bindingHandlers.numericValue = {\n init: function(element, valueAccessor, allBindings, data, context) {\n var stringified = ko.observable(ko.unwrap(valueAccessor()));\n stringified.subscribe(function(value) {\n var val = parseFloat(value);\n if (!isNaN(val)) {\n valueAccessor()(val);\n }\n });\n valueAccessor().subscribe(function(value) {\n var str = JSON.stringify(value);\n if ((str == \"0\") && ([\"-0\", \"-0.\"].indexOf(stringified()) >= 0))\n return;\n if ([\"null\", \"\"].indexOf(str) >= 0)\n return;\n stringified(str);\n });\n ko.applyBindingsToNode(\n element,\n {\n value: stringified,\n valueUpdate: allBindings.get('valueUpdate'),\n },\n context,\n );\n }\n };\n var json_data = {\"formatted_vals\":[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\"],\"changes\":WebIO.getval({\"name\":\"changes\",\"scope\":\"10057427426167816433\",\"id\":\"ob_18\",\"type\":\"observable\"}),\"index\":WebIO.getval({\"name\":\"index\",\"scope\":\"10057427426167816433\",\"id\":\"ob_17\",\"type\":\"observable\"})};\n var self = this;\n function AppViewModel() {\n for (var key in json_data) {\n var el = json_data[key];\n this[key] = Array.isArray(el) ? ko.observableArray(el) : ko.observable(el);\n }\n \n [this[\"formatted_val\"]=ko.computed( function(){\n return this.formatted_vals()[parseInt(this.index())-(1)];\n }\n,this)]\n [this[\"changes\"].subscribe((function (val){!(this.valueFromJulia[\"changes\"]) ? (WebIO.setval({\"name\":\"changes\",\"scope\":\"10057427426167816433\",\"id\":\"ob_18\",\"type\":\"observable\"},val)) : undefined; return this.valueFromJulia[\"changes\"]=false}),self),this[\"index\"].subscribe((function (val){!(this.valueFromJulia[\"index\"]) ? (WebIO.setval({\"name\":\"index\",\"scope\":\"10057427426167816433\",\"id\":\"ob_17\",\"type\":\"observable\"},val)) : undefined; return this.valueFromJulia[\"index\"]=false}),self)]\n \n }\n self.model = new AppViewModel();\n self.valueFromJulia = {};\n for (var key in json_data) {\n self.valueFromJulia[key] = false;\n }\n ko.applyBindings(self.model, self.dom);\n}\n);\n (WebIO.importBlock({\"data\":[{\"name\":\"knockout\",\"type\":\"js\",\"url\":\"/assetserver/800fa077652c804a9c5f68b6c1e29c6c61f85df7-knockout.js\"},{\"name\":\"knockout_punches\",\"type\":\"js\",\"url\":\"/assetserver/81e3f253b58efa296c3c65b00e2bf7b25de6cca9-knockout_punches.js\"}],\"type\":\"async_block\"})).then((imports) => handler.apply(this, imports));\n}\n"
],
"observables": {
"changes": {
"id": "ob_18",
"sync": false,
"value": 0
},
"index": {
"id": "ob_17",
"sync": true,
"value": 5
}
},
"systemjs_options": null
},
"nodeType": "Scope",
"props": {},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "field interact-widget"
},
"type": "node"
},
{
"children": [
{
"children": [],
"instanceArgs": {
"id": "ob_24",
"name": "obs-node"
},
"nodeType": "ObservableNode",
"props": {},
"type": "node"
}
],
"instanceArgs": {
"handlers": {},
"id": "18226143328659853009",
"imports": {
"data": [],
"type": "async_block"
},
"mount_callbacks": [],
"observables": {
"obs-node": {
"id": "ob_24",
"sync": false,
"value": {
"children": [
{
"children": [],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"setInnerHtml": "25"
},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "interact-flex-row interact-widget"
},
"type": "node"
}
}
},
"systemjs_options": null
},
"nodeType": "Scope",
"props": {},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {},
"type": "node"
},
"text/html": [
"\n",
" \n",
"
\n"
],
"text/plain": [
"Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Scope(Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :label), Any[\"i\"], Dict{Symbol,Any}(:className => \"interact \",:style => Dict{Any,Any}(:padding => \"5px 10px 0px 10px\")))], Dict{Symbol,Any}(:className => \"interact-flex-row-left\")), Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :input), Any[], Dict{Symbol,Any}(:max => 10,:min => 1,:attributes => Dict{Any,Any}(:type => \"range\",Symbol(\"data-bind\") => \"numericValue: index, valueUpdate: 'input', event: {change: function (){this.changes(this.changes()+1)}}\",\"orient\" => \"horizontal\"),:step => 1,:className => \"slider slider is-fullwidth\",:style => Dict{Any,Any}()))], Dict{Symbol,Any}(:className => \"interact-flex-row-center\")), Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :p), Any[], Dict{Symbol,Any}(:attributes => Dict(\"data-bind\" => \"text: formatted_val\")))], Dict{Symbol,Any}(:className => \"interact-flex-row-right\"))], Dict{Symbol,Any}(:className => \"interact-flex-row interact-widget\")), Dict{String,Tuple{Observables.AbstractObservable,Union{Nothing, Bool}}}(\"changes\" => (Observable{Int64} with 1 listeners. Value:\n",
"0, nothing),\"index\" => (Observable{Int64} with 2 listeners. Value:\n",
"5, nothing)), Set(String[]), nothing, Asset[Asset(\"js\", \"knockout\", \"/Users/dpsanders/.julia/packages/Knockout/IP1uR/src/../assets/knockout.js\"), Asset(\"js\", \"knockout_punches\", \"/Users/dpsanders/.julia/packages/Knockout/IP1uR/src/../assets/knockout_punches.js\"), Asset(\"js\", nothing, \"/Users/dpsanders/.julia/packages/InteractBase/9mFwe/src/../assets/all.js\"), Asset(\"css\", nothing, \"/Users/dpsanders/.julia/packages/InteractBase/9mFwe/src/../assets/style.css\"), Asset(\"css\", nothing, \"/Users/dpsanders/.julia/packages/Interact/cdOnS/src/../assets/bulma_confined.min.css\")], Dict{Any,Any}(\"changes\" => Any[WebIO.JSString(\"(function (val){return (val!=this.model[\\\"changes\\\"]()) ? (this.valueFromJulia[\\\"changes\\\"]=true, this.model[\\\"changes\\\"](val)) : undefined})\")],\"index\" => Any[WebIO.JSString(\"(function (val){return (val!=this.model[\\\"index\\\"]()) ? (this.valueFromJulia[\\\"index\\\"]=true, this.model[\\\"index\\\"](val)) : undefined})\")]), WebIO.ConnectionPool(Channel{Any}(sz_max:32,sz_curr:0), Set(AbstractConnection[]), Base.GenericCondition{Base.AlwaysLockedST}(Base.InvasiveLinkedList{Task}(Task (runnable) @0x00000001300173d0, Task (runnable) @0x00000001300173d0), Base.AlwaysLockedST(1))), WebIO.JSString[WebIO.JSString(\"function () {\\n var handler = (function (ko, koPunches) {\\n ko.punches.enableAll();\\n ko.bindingHandlers.numericValue = {\\n init: function(element, valueAccessor, allBindings, data, context) {\\n var stringified = ko.observable(ko.unwrap(valueAccessor()));\\n stringified.subscribe(function(value) {\\n var val = parseFloat(value);\\n if (!isNaN(val)) {\\n valueAccessor()(val);\\n }\\n });\\n valueAccessor().subscribe(function(value) {\\n var str = JSON.stringify(value);\\n if ((str == \\\"0\\\") && ([\\\"-0\\\", \\\"-0.\\\"].indexOf(stringified()) >= 0))\\n return;\\n if ([\\\"null\\\", \\\"\\\"].indexOf(str) >= 0)\\n return;\\n stringified(str);\\n });\\n ko.applyBindingsToNode(\\n element,\\n {\\n value: stringified,\\n valueUpdate: allBindings.get('valueUpdate'),\\n },\\n context,\\n );\\n }\\n };\\n var json_data = {\\\"formatted_vals\\\":[\\\"1\\\",\\\"2\\\",\\\"3\\\",\\\"4\\\",\\\"5\\\",\\\"6\\\",\\\"7\\\",\\\"8\\\",\\\"9\\\",\\\"10\\\"],\\\"changes\\\":WebIO.getval({\\\"name\\\":\\\"changes\\\",\\\"scope\\\":\\\"10057427426167816433\\\",\\\"id\\\":\\\"ob_18\\\",\\\"type\\\":\\\"observable\\\"}),\\\"index\\\":WebIO.getval({\\\"name\\\":\\\"index\\\",\\\"scope\\\":\\\"10057427426167816433\\\",\\\"id\\\":\\\"ob_17\\\",\\\"type\\\":\\\"observable\\\"})};\\n var self = this;\\n function AppViewModel() {\\n for (var key in json_data) {\\n var el = json_data[key];\\n this[key] = Array.isArray(el) ? ko.observableArray(el) : ko.observable(el);\\n }\\n \\n [this[\\\"formatted_val\\\"]=ko.computed( function(){\\n return this.formatted_vals()[parseInt(this.index())-(1)];\\n }\\n,this)]\\n [this[\\\"changes\\\"].subscribe((function (val){!(this.valueFromJulia[\\\"changes\\\"]) ? (WebIO.setval({\\\"name\\\":\\\"changes\\\",\\\"scope\\\":\\\"10057427426167816433\\\",\\\"id\\\":\\\"ob_18\\\",\\\"type\\\":\\\"observable\\\"},val)) : undefined; return this.valueFromJulia[\\\"changes\\\"]=false}),self),this[\\\"index\\\"].subscribe((function (val){!(this.valueFromJulia[\\\"index\\\"]) ? (WebIO.setval({\\\"name\\\":\\\"index\\\",\\\"scope\\\":\\\"10057427426167816433\\\",\\\"id\\\":\\\"ob_17\\\",\\\"type\\\":\\\"observable\\\"},val)) : undefined; return this.valueFromJulia[\\\"index\\\"]=false}),self)]\\n \\n }\\n self.model = new AppViewModel();\\n self.valueFromJulia = {};\\n for (var key in json_data) {\\n self.valueFromJulia[key] = false;\\n }\\n ko.applyBindings(self.model, self.dom);\\n}\\n);\\n (WebIO.importBlock({\\\"data\\\":[{\\\"name\\\":\\\"knockout\\\",\\\"type\\\":\\\"js\\\",\\\"url\\\":\\\"/assetserver/800fa077652c804a9c5f68b6c1e29c6c61f85df7-knockout.js\\\"},{\\\"name\\\":\\\"knockout_punches\\\",\\\"type\\\":\\\"js\\\",\\\"url\\\":\\\"/assetserver/81e3f253b58efa296c3c65b00e2bf7b25de6cca9-knockout_punches.js\\\"}],\\\"type\\\":\\\"async_block\\\"})).then((imports) => handler.apply(this, imports));\\n}\\n\")])], Dict{Symbol,Any}(:className => \"field interact-widget\")), Observable{Any} with 0 listeners. Value:\n",
"Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[HTML{Int64}(25)], Dict{Symbol,Any}(:className => \"interact-flex-row interact-widget\"))], Dict{Symbol,Any}())"
]
},
"execution_count": 47,
"metadata": {
"application/vnd.webio.node+json": {
"kernelId": "7ee91d4c-50bd-4f6b-aa33-6303bf7a1e75"
}
},
"output_type": "execute_result"
}
],
"source": [
"@manipulate for i in 1:10\n",
" HTML(i^2)\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4-element Array{String,1}:\n",
" \"Albania\"\n",
" \"Algeria\"\n",
" \"Andorra\"\n",
" \"Angola\""
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"countries = data[2:5, 2]"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"253-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",
" \"West Bank and Gaza\"\n",
" \"Guinea-Bissau\"\n",
" \"Mali\"\n",
" \"Saint Kitts and Nevis\"\n",
" \"Canada\"\n",
" \"Canada\"\n",
" \"Kosovo\"\n",
" \"Burma\"\n",
" \"United Kingdom\"\n",
" \"United Kingdom\"\n",
" \"United Kingdom\"\n",
" \"MS Zaandam\""
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"countries = data[1:end, 2]"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"253-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",
" \"West Bank and Gaza\"\n",
" \"Guinea-Bissau\"\n",
" \"Mali\"\n",
" \"Saint Kitts and Nevis\"\n",
" \"Canada\"\n",
" \"Canada\"\n",
" \"Kosovo\"\n",
" \"Burma\"\n",
" \"United Kingdom\"\n",
" \"United Kingdom\"\n",
" \"United Kingdom\"\n",
" \"MS Zaandam\""
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"countries = collect(data[:, 2])"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"177-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",
" \"Syria\"\n",
" \"Timor-Leste\"\n",
" \"Belize\"\n",
" \"Laos\"\n",
" \"Libya\"\n",
" \"West Bank and Gaza\"\n",
" \"Guinea-Bissau\"\n",
" \"Mali\"\n",
" \"Saint Kitts and Nevis\"\n",
" \"Kosovo\"\n",
" \"Burma\"\n",
" \"MS Zaandam\""
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"unique_countries = unique(countries)"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.webio.node+json": {
"children": [
{
"children": [
{
"children": [
{
"children": [
{
"children": [
{
"children": [
"i"
],
"instanceArgs": {
"namespace": "html",
"tag": "label"
},
"nodeType": "DOM",
"props": {
"className": "interact ",
"style": {
"padding": "5px 10px 0px 10px"
}
},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "interact-flex-row-left"
},
"type": "node"
},
{
"children": [
{
"children": [],
"instanceArgs": {
"namespace": "html",
"tag": "input"
},
"nodeType": "DOM",
"props": {
"attributes": {
"data-bind": "numericValue: index, valueUpdate: 'input', event: {change: function (){this.changes(this.changes()+1)}}",
"orient": "horizontal",
"type": "range"
},
"className": "slider slider is-fullwidth",
"max": 253,
"min": 1,
"step": 1,
"style": {}
},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "interact-flex-row-center"
},
"type": "node"
},
{
"children": [
{
"children": [],
"instanceArgs": {
"namespace": "html",
"tag": "p"
},
"nodeType": "DOM",
"props": {
"attributes": {
"data-bind": "text: formatted_val"
}
},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "interact-flex-row-right"
},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "interact-flex-row interact-widget"
},
"type": "node"
}
],
"instanceArgs": {
"handlers": {
"changes": [
"(function (val){return (val!=this.model[\"changes\"]()) ? (this.valueFromJulia[\"changes\"]=true, this.model[\"changes\"](val)) : undefined})"
],
"index": [
"(function (val){return (val!=this.model[\"index\"]()) ? (this.valueFromJulia[\"index\"]=true, this.model[\"index\"](val)) : undefined})"
]
},
"id": "16676976687732966261",
"imports": {
"data": [
{
"name": "knockout",
"type": "js",
"url": "/assetserver/800fa077652c804a9c5f68b6c1e29c6c61f85df7-knockout.js"
},
{
"name": "knockout_punches",
"type": "js",
"url": "/assetserver/81e3f253b58efa296c3c65b00e2bf7b25de6cca9-knockout_punches.js"
},
{
"name": null,
"type": "js",
"url": "/assetserver/5d2042c6908ffff0b7c8d26135740476bcf00827-all.js"
},
{
"name": null,
"type": "css",
"url": "/assetserver/87ad319ae61de5d44f67c268a0a8f65862fca478-style.css"
},
{
"name": null,
"type": "css",
"url": "/assetserver/a062b31556f81f574879e47f48c7fae2687f3c82-bulma_confined.min.css"
}
],
"type": "async_block"
},
"mount_callbacks": [
"function () {\n var handler = (function (ko, koPunches) {\n ko.punches.enableAll();\n ko.bindingHandlers.numericValue = {\n init: function(element, valueAccessor, allBindings, data, context) {\n var stringified = ko.observable(ko.unwrap(valueAccessor()));\n stringified.subscribe(function(value) {\n var val = parseFloat(value);\n if (!isNaN(val)) {\n valueAccessor()(val);\n }\n });\n valueAccessor().subscribe(function(value) {\n var str = JSON.stringify(value);\n if ((str == \"0\") && ([\"-0\", \"-0.\"].indexOf(stringified()) >= 0))\n return;\n if ([\"null\", \"\"].indexOf(str) >= 0)\n return;\n stringified(str);\n });\n ko.applyBindingsToNode(\n element,\n {\n value: stringified,\n valueUpdate: allBindings.get('valueUpdate'),\n },\n context,\n );\n }\n };\n var json_data = {\"formatted_vals\":[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\",\"12\",\"13\",\"14\",\"15\",\"16\",\"17\",\"18\",\"19\",\"20\",\"21\",\"22\",\"23\",\"24\",\"25\",\"26\",\"27\",\"28\",\"29\",\"30\",\"31\",\"32\",\"33\",\"34\",\"35\",\"36\",\"37\",\"38\",\"39\",\"40\",\"41\",\"42\",\"43\",\"44\",\"45\",\"46\",\"47\",\"48\",\"49\",\"50\",\"51\",\"52\",\"53\",\"54\",\"55\",\"56\",\"57\",\"58\",\"59\",\"60\",\"61\",\"62\",\"63\",\"64\",\"65\",\"66\",\"67\",\"68\",\"69\",\"70\",\"71\",\"72\",\"73\",\"74\",\"75\",\"76\",\"77\",\"78\",\"79\",\"80\",\"81\",\"82\",\"83\",\"84\",\"85\",\"86\",\"87\",\"88\",\"89\",\"90\",\"91\",\"92\",\"93\",\"94\",\"95\",\"96\",\"97\",\"98\",\"99\",\"100\",\"101\",\"102\",\"103\",\"104\",\"105\",\"106\",\"107\",\"108\",\"109\",\"110\",\"111\",\"112\",\"113\",\"114\",\"115\",\"116\",\"117\",\"118\",\"119\",\"120\",\"121\",\"122\",\"123\",\"124\",\"125\",\"126\",\"127\",\"128\",\"129\",\"130\",\"131\",\"132\",\"133\",\"134\",\"135\",\"136\",\"137\",\"138\",\"139\",\"140\",\"141\",\"142\",\"143\",\"144\",\"145\",\"146\",\"147\",\"148\",\"149\",\"150\",\"151\",\"152\",\"153\",\"154\",\"155\",\"156\",\"157\",\"158\",\"159\",\"160\",\"161\",\"162\",\"163\",\"164\",\"165\",\"166\",\"167\",\"168\",\"169\",\"170\",\"171\",\"172\",\"173\",\"174\",\"175\",\"176\",\"177\",\"178\",\"179\",\"180\",\"181\",\"182\",\"183\",\"184\",\"185\",\"186\",\"187\",\"188\",\"189\",\"190\",\"191\",\"192\",\"193\",\"194\",\"195\",\"196\",\"197\",\"198\",\"199\",\"200\",\"201\",\"202\",\"203\",\"204\",\"205\",\"206\",\"207\",\"208\",\"209\",\"210\",\"211\",\"212\",\"213\",\"214\",\"215\",\"216\",\"217\",\"218\",\"219\",\"220\",\"221\",\"222\",\"223\",\"224\",\"225\",\"226\",\"227\",\"228\",\"229\",\"230\",\"231\",\"232\",\"233\",\"234\",\"235\",\"236\",\"237\",\"238\",\"239\",\"240\",\"241\",\"242\",\"243\",\"244\",\"245\",\"246\",\"247\",\"248\",\"249\",\"250\",\"251\",\"252\",\"253\"],\"changes\":WebIO.getval({\"name\":\"changes\",\"scope\":\"16676976687732966261\",\"id\":\"ob_26\",\"type\":\"observable\"}),\"index\":WebIO.getval({\"name\":\"index\",\"scope\":\"16676976687732966261\",\"id\":\"ob_25\",\"type\":\"observable\"})};\n var self = this;\n function AppViewModel() {\n for (var key in json_data) {\n var el = json_data[key];\n this[key] = Array.isArray(el) ? ko.observableArray(el) : ko.observable(el);\n }\n \n [this[\"formatted_val\"]=ko.computed( function(){\n return this.formatted_vals()[parseInt(this.index())-(1)];\n }\n,this)]\n [this[\"changes\"].subscribe((function (val){!(this.valueFromJulia[\"changes\"]) ? (WebIO.setval({\"name\":\"changes\",\"scope\":\"16676976687732966261\",\"id\":\"ob_26\",\"type\":\"observable\"},val)) : undefined; return this.valueFromJulia[\"changes\"]=false}),self),this[\"index\"].subscribe((function (val){!(this.valueFromJulia[\"index\"]) ? (WebIO.setval({\"name\":\"index\",\"scope\":\"16676976687732966261\",\"id\":\"ob_25\",\"type\":\"observable\"},val)) : undefined; return this.valueFromJulia[\"index\"]=false}),self)]\n \n }\n self.model = new AppViewModel();\n self.valueFromJulia = {};\n for (var key in json_data) {\n self.valueFromJulia[key] = false;\n }\n ko.applyBindings(self.model, self.dom);\n}\n);\n (WebIO.importBlock({\"data\":[{\"name\":\"knockout\",\"type\":\"js\",\"url\":\"/assetserver/800fa077652c804a9c5f68b6c1e29c6c61f85df7-knockout.js\"},{\"name\":\"knockout_punches\",\"type\":\"js\",\"url\":\"/assetserver/81e3f253b58efa296c3c65b00e2bf7b25de6cca9-knockout_punches.js\"}],\"type\":\"async_block\"})).then((imports) => handler.apply(this, imports));\n}\n"
],
"observables": {
"changes": {
"id": "ob_26",
"sync": false,
"value": 0
},
"index": {
"id": "ob_25",
"sync": true,
"value": 127
}
},
"systemjs_options": null
},
"nodeType": "Scope",
"props": {},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "field interact-widget"
},
"type": "node"
},
{
"children": [
{
"children": [],
"instanceArgs": {
"id": "ob_32",
"name": "obs-node"
},
"nodeType": "ObservableNode",
"props": {},
"type": "node"
}
],
"instanceArgs": {
"handlers": {},
"id": "8181955358512377695",
"imports": {
"data": [],
"type": "async_block"
},
"mount_callbacks": [],
"observables": {
"obs-node": {
"id": "ob_32",
"sync": false,
"value": {
"children": [
"Haiti"
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "interact-flex-row interact-widget"
},
"type": "node"
}
}
},
"systemjs_options": null
},
"nodeType": "Scope",
"props": {},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {},
"type": "node"
},
"text/html": [
"\n",
" \n",
"
\n"
],
"text/plain": [
"Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Scope(Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :label), Any[\"i\"], Dict{Symbol,Any}(:className => \"interact \",:style => Dict{Any,Any}(:padding => \"5px 10px 0px 10px\")))], Dict{Symbol,Any}(:className => \"interact-flex-row-left\")), Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :input), Any[], Dict{Symbol,Any}(:max => 253,:min => 1,:attributes => Dict{Any,Any}(:type => \"range\",Symbol(\"data-bind\") => \"numericValue: index, valueUpdate: 'input', event: {change: function (){this.changes(this.changes()+1)}}\",\"orient\" => \"horizontal\"),:step => 1,:className => \"slider slider is-fullwidth\",:style => Dict{Any,Any}()))], Dict{Symbol,Any}(:className => \"interact-flex-row-center\")), Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :p), Any[], Dict{Symbol,Any}(:attributes => Dict(\"data-bind\" => \"text: formatted_val\")))], Dict{Symbol,Any}(:className => \"interact-flex-row-right\"))], Dict{Symbol,Any}(:className => \"interact-flex-row interact-widget\")), Dict{String,Tuple{Observables.AbstractObservable,Union{Nothing, Bool}}}(\"changes\" => (Observable{Int64} with 1 listeners. Value:\n",
"0, nothing),\"index\" => (Observable{Int64} with 2 listeners. Value:\n",
"127, nothing)), Set(String[]), nothing, Asset[Asset(\"js\", \"knockout\", \"/Users/dpsanders/.julia/packages/Knockout/IP1uR/src/../assets/knockout.js\"), Asset(\"js\", \"knockout_punches\", \"/Users/dpsanders/.julia/packages/Knockout/IP1uR/src/../assets/knockout_punches.js\"), Asset(\"js\", nothing, \"/Users/dpsanders/.julia/packages/InteractBase/9mFwe/src/../assets/all.js\"), Asset(\"css\", nothing, \"/Users/dpsanders/.julia/packages/InteractBase/9mFwe/src/../assets/style.css\"), Asset(\"css\", nothing, \"/Users/dpsanders/.julia/packages/Interact/cdOnS/src/../assets/bulma_confined.min.css\")], Dict{Any,Any}(\"changes\" => Any[WebIO.JSString(\"(function (val){return (val!=this.model[\\\"changes\\\"]()) ? (this.valueFromJulia[\\\"changes\\\"]=true, this.model[\\\"changes\\\"](val)) : undefined})\")],\"index\" => Any[WebIO.JSString(\"(function (val){return (val!=this.model[\\\"index\\\"]()) ? (this.valueFromJulia[\\\"index\\\"]=true, this.model[\\\"index\\\"](val)) : undefined})\")]), WebIO.ConnectionPool(Channel{Any}(sz_max:32,sz_curr:0), Set(AbstractConnection[]), Base.GenericCondition{Base.AlwaysLockedST}(Base.InvasiveLinkedList{Task}(Task (runnable) @0x0000000115ff1210, Task (runnable) @0x0000000115ff1210), Base.AlwaysLockedST(1))), WebIO.JSString[WebIO.JSString(\"function () {\\n var handler = (function (ko, koPunches) {\\n ko.punches.enableAll();\\n ko.bindingHandlers.numericValue = {\\n init: function(element, valueAccessor, allBindings, data, context) {\\n var stringified = ko.observable(ko.unwrap(valueAccessor()));\\n stringified.subscribe(function(value) {\\n var val = parseFloat(value);\\n if (!isNaN(val)) {\\n valueAccessor()(val);\\n }\\n });\\n valueAccessor().subscribe(function(value) {\\n var str = JSON.stringify(value);\\n if ((str == \\\"0\\\") && ([\\\"-0\\\", \\\"-0.\\\"].indexOf(stringified()) >= 0))\\n return;\\n if ([\\\"null\\\", \\\"\\\"].indexOf(str) >= 0)\\n return;\\n stringified(str);\\n });\\n ko.applyBindingsToNode(\\n element,\\n {\\n value: stringified,\\n valueUpdate: allBindings.get('valueUpdate'),\\n },\\n context,\\n );\\n }\\n };\\n var json_data = {\\\"formatted_vals\\\":[\\\"1\\\",\\\"2\\\",\\\"3\\\",\\\"4\\\",\\\"5\\\",\\\"6\\\",\\\"7\\\",\\\"8\\\",\\\"9\\\",\\\"10\\\",\\\"11\\\",\\\"12\\\",\\\"13\\\",\\\"14\\\",\\\"15\\\",\\\"16\\\",\\\"17\\\",\\\"18\\\",\\\"19\\\",\\\"20\\\",\\\"21\\\",\\\"22\\\",\\\"23\\\",\\\"24\\\",\\\"25\\\",\\\"26\\\",\\\"27\\\",\\\"28\\\",\\\"29\\\",\\\"30\\\",\\\"31\\\",\\\"32\\\",\\\"33\\\",\\\"34\\\",\\\"35\\\",\\\"36\\\",\\\"37\\\",\\\"38\\\",\\\"39\\\",\\\"40\\\",\\\"41\\\",\\\"42\\\",\\\"43\\\",\\\"44\\\",\\\"45\\\",\\\"46\\\",\\\"47\\\",\\\"48\\\",\\\"49\\\",\\\"50\\\",\\\"51\\\",\\\"52\\\",\\\"53\\\",\\\"54\\\",\\\"55\\\",\\\"56\\\",\\\"57\\\",\\\"58\\\",\\\"59\\\",\\\"60\\\",\\\"61\\\",\\\"62\\\",\\\"63\\\",\\\"64\\\",\\\"65\\\",\\\"66\\\",\\\"67\\\",\\\"68\\\",\\\"69\\\",\\\"70\\\",\\\"71\\\",\\\"72\\\",\\\"73\\\",\\\"74\\\",\\\"75\\\",\\\"76\\\",\\\"77\\\",\\\"78\\\",\\\"79\\\",\\\"80\\\",\\\"81\\\",\\\"82\\\",\\\"83\\\",\\\"84\\\",\\\"85\\\",\\\"86\\\",\\\"87\\\",\\\"88\\\",\\\"89\\\",\\\"90\\\",\\\"91\\\",\\\"92\\\",\\\"93\\\",\\\"94\\\",\\\"95\\\",\\\"96\\\",\\\"97\\\",\\\"98\\\",\\\"99\\\",\\\"100\\\",\\\"101\\\",\\\"102\\\",\\\"103\\\",\\\"104\\\",\\\"105\\\",\\\"106\\\",\\\"107\\\",\\\"108\\\",\\\"109\\\",\\\"110\\\",\\\"111\\\",\\\"112\\\",\\\"113\\\",\\\"114\\\",\\\"115\\\",\\\"116\\\",\\\"117\\\",\\\"118\\\",\\\"119\\\",\\\"120\\\",\\\"121\\\",\\\"122\\\",\\\"123\\\",\\\"124\\\",\\\"125\\\",\\\"126\\\",\\\"127\\\",\\\"128\\\",\\\"129\\\",\\\"130\\\",\\\"131\\\",\\\"132\\\",\\\"133\\\",\\\"134\\\",\\\"135\\\",\\\"136\\\",\\\"137\\\",\\\"138\\\",\\\"139\\\",\\\"140\\\",\\\"141\\\",\\\"142\\\",\\\"143\\\",\\\"144\\\",\\\"145\\\",\\\"146\\\",\\\"147\\\",\\\"148\\\",\\\"149\\\",\\\"150\\\",\\\"151\\\",\\\"152\\\",\\\"153\\\",\\\"154\\\",\\\"155\\\",\\\"156\\\",\\\"157\\\",\\\"158\\\",\\\"159\\\",\\\"160\\\",\\\"161\\\",\\\"162\\\",\\\"163\\\",\\\"164\\\",\\\"165\\\",\\\"166\\\",\\\"167\\\",\\\"168\\\",\\\"169\\\",\\\"170\\\",\\\"171\\\",\\\"172\\\",\\\"173\\\",\\\"174\\\",\\\"175\\\",\\\"176\\\",\\\"177\\\",\\\"178\\\",\\\"179\\\",\\\"180\\\",\\\"181\\\",\\\"182\\\",\\\"183\\\",\\\"184\\\",\\\"185\\\",\\\"186\\\",\\\"187\\\",\\\"188\\\",\\\"189\\\",\\\"190\\\",\\\"191\\\",\\\"192\\\",\\\"193\\\",\\\"194\\\",\\\"195\\\",\\\"196\\\",\\\"197\\\",\\\"198\\\",\\\"199\\\",\\\"200\\\",\\\"201\\\",\\\"202\\\",\\\"203\\\",\\\"204\\\",\\\"205\\\",\\\"206\\\",\\\"207\\\",\\\"208\\\",\\\"209\\\",\\\"210\\\",\\\"211\\\",\\\"212\\\",\\\"213\\\",\\\"214\\\",\\\"215\\\",\\\"216\\\",\\\"217\\\",\\\"218\\\",\\\"219\\\",\\\"220\\\",\\\"221\\\",\\\"222\\\",\\\"223\\\",\\\"224\\\",\\\"225\\\",\\\"226\\\",\\\"227\\\",\\\"228\\\",\\\"229\\\",\\\"230\\\",\\\"231\\\",\\\"232\\\",\\\"233\\\",\\\"234\\\",\\\"235\\\",\\\"236\\\",\\\"237\\\",\\\"238\\\",\\\"239\\\",\\\"240\\\",\\\"241\\\",\\\"242\\\",\\\"243\\\",\\\"244\\\",\\\"245\\\",\\\"246\\\",\\\"247\\\",\\\"248\\\",\\\"249\\\",\\\"250\\\",\\\"251\\\",\\\"252\\\",\\\"253\\\"],\\\"changes\\\":WebIO.getval({\\\"name\\\":\\\"changes\\\",\\\"scope\\\":\\\"16676976687732966261\\\",\\\"id\\\":\\\"ob_26\\\",\\\"type\\\":\\\"observable\\\"}),\\\"index\\\":WebIO.getval({\\\"name\\\":\\\"index\\\",\\\"scope\\\":\\\"16676976687732966261\\\",\\\"id\\\":\\\"ob_25\\\",\\\"type\\\":\\\"observable\\\"})};\\n var self = this;\\n function AppViewModel() {\\n for (var key in json_data) {\\n var el = json_data[key];\\n this[key] = Array.isArray(el) ? ko.observableArray(el) : ko.observable(el);\\n }\\n \\n [this[\\\"formatted_val\\\"]=ko.computed( function(){\\n return this.formatted_vals()[parseInt(this.index())-(1)];\\n }\\n,this)]\\n [this[\\\"changes\\\"].subscribe((function (val){!(this.valueFromJulia[\\\"changes\\\"]) ? (WebIO.setval({\\\"name\\\":\\\"changes\\\",\\\"scope\\\":\\\"16676976687732966261\\\",\\\"id\\\":\\\"ob_26\\\",\\\"type\\\":\\\"observable\\\"},val)) : undefined; return this.valueFromJulia[\\\"changes\\\"]=false}),self),this[\\\"index\\\"].subscribe((function (val){!(this.valueFromJulia[\\\"index\\\"]) ? (WebIO.setval({\\\"name\\\":\\\"index\\\",\\\"scope\\\":\\\"16676976687732966261\\\",\\\"id\\\":\\\"ob_25\\\",\\\"type\\\":\\\"observable\\\"},val)) : undefined; return this.valueFromJulia[\\\"index\\\"]=false}),self)]\\n \\n }\\n self.model = new AppViewModel();\\n self.valueFromJulia = {};\\n for (var key in json_data) {\\n self.valueFromJulia[key] = false;\\n }\\n ko.applyBindings(self.model, self.dom);\\n}\\n);\\n (WebIO.importBlock({\\\"data\\\":[{\\\"name\\\":\\\"knockout\\\",\\\"type\\\":\\\"js\\\",\\\"url\\\":\\\"/assetserver/800fa077652c804a9c5f68b6c1e29c6c61f85df7-knockout.js\\\"},{\\\"name\\\":\\\"knockout_punches\\\",\\\"type\\\":\\\"js\\\",\\\"url\\\":\\\"/assetserver/81e3f253b58efa296c3c65b00e2bf7b25de6cca9-knockout_punches.js\\\"}],\\\"type\\\":\\\"async_block\\\"})).then((imports) => handler.apply(this, imports));\\n}\\n\")])], Dict{Symbol,Any}(:className => \"field interact-widget\")), Observable{Any} with 0 listeners. Value:\n",
"Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[\"Haiti\"], Dict{Symbol,Any}(:className => \"interact-flex-row interact-widget\"))], Dict{Symbol,Any}())"
]
},
"execution_count": 54,
"metadata": {
"application/vnd.webio.node+json": {
"kernelId": "7ee91d4c-50bd-4f6b-aa33-6303bf7a1e75"
}
},
"output_type": "execute_result"
}
],
"source": [
"@manipulate for i in 1:length(countries)\n",
" countries[i]\n",
"end"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Julia has 1-based indexing: indices of vectors start at 1, not 0 "
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.webio.node+json": {
"children": [
{
"children": [
{
"children": [
{
"children": [
{
"children": [
{
"children": [
"i"
],
"instanceArgs": {
"namespace": "html",
"tag": "label"
},
"nodeType": "DOM",
"props": {
"className": "interact ",
"style": {
"padding": "5px 10px 0px 10px"
}
},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "interact-flex-row-left"
},
"type": "node"
},
{
"children": [
{
"children": [],
"instanceArgs": {
"namespace": "html",
"tag": "input"
},
"nodeType": "DOM",
"props": {
"attributes": {
"data-bind": "numericValue: index, valueUpdate: 'input', event: {change: function (){this.changes(this.changes()+1)}}",
"orient": "horizontal",
"type": "range"
},
"className": "slider slider is-fullwidth",
"max": 253,
"min": 1,
"step": 1,
"style": {}
},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "interact-flex-row-center"
},
"type": "node"
},
{
"children": [
{
"children": [],
"instanceArgs": {
"namespace": "html",
"tag": "p"
},
"nodeType": "DOM",
"props": {
"attributes": {
"data-bind": "text: formatted_val"
}
},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "interact-flex-row-right"
},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "interact-flex-row interact-widget"
},
"type": "node"
}
],
"instanceArgs": {
"handlers": {
"changes": [
"(function (val){return (val!=this.model[\"changes\"]()) ? (this.valueFromJulia[\"changes\"]=true, this.model[\"changes\"](val)) : undefined})"
],
"index": [
"(function (val){return (val!=this.model[\"index\"]()) ? (this.valueFromJulia[\"index\"]=true, this.model[\"index\"](val)) : undefined})"
]
},
"id": "16447016175433825225",
"imports": {
"data": [
{
"name": "knockout",
"type": "js",
"url": "/assetserver/800fa077652c804a9c5f68b6c1e29c6c61f85df7-knockout.js"
},
{
"name": "knockout_punches",
"type": "js",
"url": "/assetserver/81e3f253b58efa296c3c65b00e2bf7b25de6cca9-knockout_punches.js"
},
{
"name": null,
"type": "js",
"url": "/assetserver/5d2042c6908ffff0b7c8d26135740476bcf00827-all.js"
},
{
"name": null,
"type": "css",
"url": "/assetserver/87ad319ae61de5d44f67c268a0a8f65862fca478-style.css"
},
{
"name": null,
"type": "css",
"url": "/assetserver/a062b31556f81f574879e47f48c7fae2687f3c82-bulma_confined.min.css"
}
],
"type": "async_block"
},
"mount_callbacks": [
"function () {\n var handler = (function (ko, koPunches) {\n ko.punches.enableAll();\n ko.bindingHandlers.numericValue = {\n init: function(element, valueAccessor, allBindings, data, context) {\n var stringified = ko.observable(ko.unwrap(valueAccessor()));\n stringified.subscribe(function(value) {\n var val = parseFloat(value);\n if (!isNaN(val)) {\n valueAccessor()(val);\n }\n });\n valueAccessor().subscribe(function(value) {\n var str = JSON.stringify(value);\n if ((str == \"0\") && ([\"-0\", \"-0.\"].indexOf(stringified()) >= 0))\n return;\n if ([\"null\", \"\"].indexOf(str) >= 0)\n return;\n stringified(str);\n });\n ko.applyBindingsToNode(\n element,\n {\n value: stringified,\n valueUpdate: allBindings.get('valueUpdate'),\n },\n context,\n );\n }\n };\n var json_data = {\"formatted_vals\":[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\",\"12\",\"13\",\"14\",\"15\",\"16\",\"17\",\"18\",\"19\",\"20\",\"21\",\"22\",\"23\",\"24\",\"25\",\"26\",\"27\",\"28\",\"29\",\"30\",\"31\",\"32\",\"33\",\"34\",\"35\",\"36\",\"37\",\"38\",\"39\",\"40\",\"41\",\"42\",\"43\",\"44\",\"45\",\"46\",\"47\",\"48\",\"49\",\"50\",\"51\",\"52\",\"53\",\"54\",\"55\",\"56\",\"57\",\"58\",\"59\",\"60\",\"61\",\"62\",\"63\",\"64\",\"65\",\"66\",\"67\",\"68\",\"69\",\"70\",\"71\",\"72\",\"73\",\"74\",\"75\",\"76\",\"77\",\"78\",\"79\",\"80\",\"81\",\"82\",\"83\",\"84\",\"85\",\"86\",\"87\",\"88\",\"89\",\"90\",\"91\",\"92\",\"93\",\"94\",\"95\",\"96\",\"97\",\"98\",\"99\",\"100\",\"101\",\"102\",\"103\",\"104\",\"105\",\"106\",\"107\",\"108\",\"109\",\"110\",\"111\",\"112\",\"113\",\"114\",\"115\",\"116\",\"117\",\"118\",\"119\",\"120\",\"121\",\"122\",\"123\",\"124\",\"125\",\"126\",\"127\",\"128\",\"129\",\"130\",\"131\",\"132\",\"133\",\"134\",\"135\",\"136\",\"137\",\"138\",\"139\",\"140\",\"141\",\"142\",\"143\",\"144\",\"145\",\"146\",\"147\",\"148\",\"149\",\"150\",\"151\",\"152\",\"153\",\"154\",\"155\",\"156\",\"157\",\"158\",\"159\",\"160\",\"161\",\"162\",\"163\",\"164\",\"165\",\"166\",\"167\",\"168\",\"169\",\"170\",\"171\",\"172\",\"173\",\"174\",\"175\",\"176\",\"177\",\"178\",\"179\",\"180\",\"181\",\"182\",\"183\",\"184\",\"185\",\"186\",\"187\",\"188\",\"189\",\"190\",\"191\",\"192\",\"193\",\"194\",\"195\",\"196\",\"197\",\"198\",\"199\",\"200\",\"201\",\"202\",\"203\",\"204\",\"205\",\"206\",\"207\",\"208\",\"209\",\"210\",\"211\",\"212\",\"213\",\"214\",\"215\",\"216\",\"217\",\"218\",\"219\",\"220\",\"221\",\"222\",\"223\",\"224\",\"225\",\"226\",\"227\",\"228\",\"229\",\"230\",\"231\",\"232\",\"233\",\"234\",\"235\",\"236\",\"237\",\"238\",\"239\",\"240\",\"241\",\"242\",\"243\",\"244\",\"245\",\"246\",\"247\",\"248\",\"249\",\"250\",\"251\",\"252\",\"253\"],\"changes\":WebIO.getval({\"name\":\"changes\",\"scope\":\"16447016175433825225\",\"id\":\"ob_50\",\"type\":\"observable\"}),\"index\":WebIO.getval({\"name\":\"index\",\"scope\":\"16447016175433825225\",\"id\":\"ob_49\",\"type\":\"observable\"})};\n var self = this;\n function AppViewModel() {\n for (var key in json_data) {\n var el = json_data[key];\n this[key] = Array.isArray(el) ? ko.observableArray(el) : ko.observable(el);\n }\n \n [this[\"formatted_val\"]=ko.computed( function(){\n return this.formatted_vals()[parseInt(this.index())-(1)];\n }\n,this)]\n [this[\"changes\"].subscribe((function (val){!(this.valueFromJulia[\"changes\"]) ? (WebIO.setval({\"name\":\"changes\",\"scope\":\"16447016175433825225\",\"id\":\"ob_50\",\"type\":\"observable\"},val)) : undefined; return this.valueFromJulia[\"changes\"]=false}),self),this[\"index\"].subscribe((function (val){!(this.valueFromJulia[\"index\"]) ? (WebIO.setval({\"name\":\"index\",\"scope\":\"16447016175433825225\",\"id\":\"ob_49\",\"type\":\"observable\"},val)) : undefined; return this.valueFromJulia[\"index\"]=false}),self)]\n \n }\n self.model = new AppViewModel();\n self.valueFromJulia = {};\n for (var key in json_data) {\n self.valueFromJulia[key] = false;\n }\n ko.applyBindings(self.model, self.dom);\n}\n);\n (WebIO.importBlock({\"data\":[{\"name\":\"knockout\",\"type\":\"js\",\"url\":\"/assetserver/800fa077652c804a9c5f68b6c1e29c6c61f85df7-knockout.js\"},{\"name\":\"knockout_punches\",\"type\":\"js\",\"url\":\"/assetserver/81e3f253b58efa296c3c65b00e2bf7b25de6cca9-knockout_punches.js\"}],\"type\":\"async_block\"})).then((imports) => handler.apply(this, imports));\n}\n"
],
"observables": {
"changes": {
"id": "ob_50",
"sync": false,
"value": 0
},
"index": {
"id": "ob_49",
"sync": true,
"value": 127
}
},
"systemjs_options": null
},
"nodeType": "Scope",
"props": {},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "field interact-widget"
},
"type": "node"
},
{
"children": [
{
"children": [],
"instanceArgs": {
"id": "ob_56",
"name": "obs-node"
},
"nodeType": "ObservableNode",
"props": {},
"type": "node"
}
],
"instanceArgs": {
"handlers": {},
"id": "4496921208839785326",
"imports": {
"data": [],
"type": "async_block"
},
"mount_callbacks": [],
"observables": {
"obs-node": {
"id": "ob_56",
"sync": false,
"value": {
"children": [
{
"children": [],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"setInnerHtml": "DataFrameRow (15 columns)
province country Lat Long 1/22/20 1/23/20 1/24/20 1/25/20 1/26/20 1/27/20 1/28/20 1/29/20 1/30/20 1/31/20 2/1/20 String⍰ String Float64 Float64 Int64 Int64 Int64 Int64 Int64 Int64 Int64 Int64 Int64 Int64 Int64 127 missing Haiti 18.9712 -72.2852 0 0 0 0 0 0 0 0 0 0 0
"
},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {
"className": "interact-flex-row interact-widget"
},
"type": "node"
}
}
},
"systemjs_options": null
},
"nodeType": "Scope",
"props": {},
"type": "node"
}
],
"instanceArgs": {
"namespace": "html",
"tag": "div"
},
"nodeType": "DOM",
"props": {},
"type": "node"
},
"text/html": [
"\n",
" \n",
"
\n"
],
"text/plain": [
"Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Scope(Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :label), Any[\"i\"], Dict{Symbol,Any}(:className => \"interact \",:style => Dict{Any,Any}(:padding => \"5px 10px 0px 10px\")))], Dict{Symbol,Any}(:className => \"interact-flex-row-left\")), Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :input), Any[], Dict{Symbol,Any}(:max => 253,:min => 1,:attributes => Dict{Any,Any}(:type => \"range\",Symbol(\"data-bind\") => \"numericValue: index, valueUpdate: 'input', event: {change: function (){this.changes(this.changes()+1)}}\",\"orient\" => \"horizontal\"),:step => 1,:className => \"slider slider is-fullwidth\",:style => Dict{Any,Any}()))], Dict{Symbol,Any}(:className => \"interact-flex-row-center\")), Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :p), Any[], Dict{Symbol,Any}(:attributes => Dict(\"data-bind\" => \"text: formatted_val\")))], Dict{Symbol,Any}(:className => \"interact-flex-row-right\"))], Dict{Symbol,Any}(:className => \"interact-flex-row interact-widget\")), Dict{String,Tuple{Observables.AbstractObservable,Union{Nothing, Bool}}}(\"changes\" => (Observable{Int64} with 1 listeners. Value:\n",
"0, nothing),\"index\" => (Observable{Int64} with 2 listeners. Value:\n",
"127, nothing)), Set(String[]), nothing, Asset[Asset(\"js\", \"knockout\", \"/Users/dpsanders/.julia/packages/Knockout/IP1uR/src/../assets/knockout.js\"), Asset(\"js\", \"knockout_punches\", \"/Users/dpsanders/.julia/packages/Knockout/IP1uR/src/../assets/knockout_punches.js\"), Asset(\"js\", nothing, \"/Users/dpsanders/.julia/packages/InteractBase/9mFwe/src/../assets/all.js\"), Asset(\"css\", nothing, \"/Users/dpsanders/.julia/packages/InteractBase/9mFwe/src/../assets/style.css\"), Asset(\"css\", nothing, \"/Users/dpsanders/.julia/packages/Interact/cdOnS/src/../assets/bulma_confined.min.css\")], Dict{Any,Any}(\"changes\" => Any[WebIO.JSString(\"(function (val){return (val!=this.model[\\\"changes\\\"]()) ? (this.valueFromJulia[\\\"changes\\\"]=true, this.model[\\\"changes\\\"](val)) : undefined})\")],\"index\" => Any[WebIO.JSString(\"(function (val){return (val!=this.model[\\\"index\\\"]()) ? (this.valueFromJulia[\\\"index\\\"]=true, this.model[\\\"index\\\"](val)) : undefined})\")]), WebIO.ConnectionPool(Channel{Any}(sz_max:32,sz_curr:0), Set(AbstractConnection[]), Base.GenericCondition{Base.AlwaysLockedST}(Base.InvasiveLinkedList{Task}(Task (runnable) @0x0000000130015690, Task (runnable) @0x0000000130015690), Base.AlwaysLockedST(1))), WebIO.JSString[WebIO.JSString(\"function () {\\n var handler = (function (ko, koPunches) {\\n ko.punches.enableAll();\\n ko.bindingHandlers.numericValue = {\\n init: function(element, valueAccessor, allBindings, data, context) {\\n var stringified = ko.observable(ko.unwrap(valueAccessor()));\\n stringified.subscribe(function(value) {\\n var val = parseFloat(value);\\n if (!isNaN(val)) {\\n valueAccessor()(val);\\n }\\n });\\n valueAccessor().subscribe(function(value) {\\n var str = JSON.stringify(value);\\n if ((str == \\\"0\\\") && ([\\\"-0\\\", \\\"-0.\\\"].indexOf(stringified()) >= 0))\\n return;\\n if ([\\\"null\\\", \\\"\\\"].indexOf(str) >= 0)\\n return;\\n stringified(str);\\n });\\n ko.applyBindingsToNode(\\n element,\\n {\\n value: stringified,\\n valueUpdate: allBindings.get('valueUpdate'),\\n },\\n context,\\n );\\n }\\n };\\n var json_data = {\\\"formatted_vals\\\":[\\\"1\\\",\\\"2\\\",\\\"3\\\",\\\"4\\\",\\\"5\\\",\\\"6\\\",\\\"7\\\",\\\"8\\\",\\\"9\\\",\\\"10\\\",\\\"11\\\",\\\"12\\\",\\\"13\\\",\\\"14\\\",\\\"15\\\",\\\"16\\\",\\\"17\\\",\\\"18\\\",\\\"19\\\",\\\"20\\\",\\\"21\\\",\\\"22\\\",\\\"23\\\",\\\"24\\\",\\\"25\\\",\\\"26\\\",\\\"27\\\",\\\"28\\\",\\\"29\\\",\\\"30\\\",\\\"31\\\",\\\"32\\\",\\\"33\\\",\\\"34\\\",\\\"35\\\",\\\"36\\\",\\\"37\\\",\\\"38\\\",\\\"39\\\",\\\"40\\\",\\\"41\\\",\\\"42\\\",\\\"43\\\",\\\"44\\\",\\\"45\\\",\\\"46\\\",\\\"47\\\",\\\"48\\\",\\\"49\\\",\\\"50\\\",\\\"51\\\",\\\"52\\\",\\\"53\\\",\\\"54\\\",\\\"55\\\",\\\"56\\\",\\\"57\\\",\\\"58\\\",\\\"59\\\",\\\"60\\\",\\\"61\\\",\\\"62\\\",\\\"63\\\",\\\"64\\\",\\\"65\\\",\\\"66\\\",\\\"67\\\",\\\"68\\\",\\\"69\\\",\\\"70\\\",\\\"71\\\",\\\"72\\\",\\\"73\\\",\\\"74\\\",\\\"75\\\",\\\"76\\\",\\\"77\\\",\\\"78\\\",\\\"79\\\",\\\"80\\\",\\\"81\\\",\\\"82\\\",\\\"83\\\",\\\"84\\\",\\\"85\\\",\\\"86\\\",\\\"87\\\",\\\"88\\\",\\\"89\\\",\\\"90\\\",\\\"91\\\",\\\"92\\\",\\\"93\\\",\\\"94\\\",\\\"95\\\",\\\"96\\\",\\\"97\\\",\\\"98\\\",\\\"99\\\",\\\"100\\\",\\\"101\\\",\\\"102\\\",\\\"103\\\",\\\"104\\\",\\\"105\\\",\\\"106\\\",\\\"107\\\",\\\"108\\\",\\\"109\\\",\\\"110\\\",\\\"111\\\",\\\"112\\\",\\\"113\\\",\\\"114\\\",\\\"115\\\",\\\"116\\\",\\\"117\\\",\\\"118\\\",\\\"119\\\",\\\"120\\\",\\\"121\\\",\\\"122\\\",\\\"123\\\",\\\"124\\\",\\\"125\\\",\\\"126\\\",\\\"127\\\",\\\"128\\\",\\\"129\\\",\\\"130\\\",\\\"131\\\",\\\"132\\\",\\\"133\\\",\\\"134\\\",\\\"135\\\",\\\"136\\\",\\\"137\\\",\\\"138\\\",\\\"139\\\",\\\"140\\\",\\\"141\\\",\\\"142\\\",\\\"143\\\",\\\"144\\\",\\\"145\\\",\\\"146\\\",\\\"147\\\",\\\"148\\\",\\\"149\\\",\\\"150\\\",\\\"151\\\",\\\"152\\\",\\\"153\\\",\\\"154\\\",\\\"155\\\",\\\"156\\\",\\\"157\\\",\\\"158\\\",\\\"159\\\",\\\"160\\\",\\\"161\\\",\\\"162\\\",\\\"163\\\",\\\"164\\\",\\\"165\\\",\\\"166\\\",\\\"167\\\",\\\"168\\\",\\\"169\\\",\\\"170\\\",\\\"171\\\",\\\"172\\\",\\\"173\\\",\\\"174\\\",\\\"175\\\",\\\"176\\\",\\\"177\\\",\\\"178\\\",\\\"179\\\",\\\"180\\\",\\\"181\\\",\\\"182\\\",\\\"183\\\",\\\"184\\\",\\\"185\\\",\\\"186\\\",\\\"187\\\",\\\"188\\\",\\\"189\\\",\\\"190\\\",\\\"191\\\",\\\"192\\\",\\\"193\\\",\\\"194\\\",\\\"195\\\",\\\"196\\\",\\\"197\\\",\\\"198\\\",\\\"199\\\",\\\"200\\\",\\\"201\\\",\\\"202\\\",\\\"203\\\",\\\"204\\\",\\\"205\\\",\\\"206\\\",\\\"207\\\",\\\"208\\\",\\\"209\\\",\\\"210\\\",\\\"211\\\",\\\"212\\\",\\\"213\\\",\\\"214\\\",\\\"215\\\",\\\"216\\\",\\\"217\\\",\\\"218\\\",\\\"219\\\",\\\"220\\\",\\\"221\\\",\\\"222\\\",\\\"223\\\",\\\"224\\\",\\\"225\\\",\\\"226\\\",\\\"227\\\",\\\"228\\\",\\\"229\\\",\\\"230\\\",\\\"231\\\",\\\"232\\\",\\\"233\\\",\\\"234\\\",\\\"235\\\",\\\"236\\\",\\\"237\\\",\\\"238\\\",\\\"239\\\",\\\"240\\\",\\\"241\\\",\\\"242\\\",\\\"243\\\",\\\"244\\\",\\\"245\\\",\\\"246\\\",\\\"247\\\",\\\"248\\\",\\\"249\\\",\\\"250\\\",\\\"251\\\",\\\"252\\\",\\\"253\\\"],\\\"changes\\\":WebIO.getval({\\\"name\\\":\\\"changes\\\",\\\"scope\\\":\\\"16447016175433825225\\\",\\\"id\\\":\\\"ob_50\\\",\\\"type\\\":\\\"observable\\\"}),\\\"index\\\":WebIO.getval({\\\"name\\\":\\\"index\\\",\\\"scope\\\":\\\"16447016175433825225\\\",\\\"id\\\":\\\"ob_49\\\",\\\"type\\\":\\\"observable\\\"})};\\n var self = this;\\n function AppViewModel() {\\n for (var key in json_data) {\\n var el = json_data[key];\\n this[key] = Array.isArray(el) ? ko.observableArray(el) : ko.observable(el);\\n }\\n \\n [this[\\\"formatted_val\\\"]=ko.computed( function(){\\n return this.formatted_vals()[parseInt(this.index())-(1)];\\n }\\n,this)]\\n [this[\\\"changes\\\"].subscribe((function (val){!(this.valueFromJulia[\\\"changes\\\"]) ? (WebIO.setval({\\\"name\\\":\\\"changes\\\",\\\"scope\\\":\\\"16447016175433825225\\\",\\\"id\\\":\\\"ob_50\\\",\\\"type\\\":\\\"observable\\\"},val)) : undefined; return this.valueFromJulia[\\\"changes\\\"]=false}),self),this[\\\"index\\\"].subscribe((function (val){!(this.valueFromJulia[\\\"index\\\"]) ? (WebIO.setval({\\\"name\\\":\\\"index\\\",\\\"scope\\\":\\\"16447016175433825225\\\",\\\"id\\\":\\\"ob_49\\\",\\\"type\\\":\\\"observable\\\"},val)) : undefined; return this.valueFromJulia[\\\"index\\\"]=false}),self)]\\n \\n }\\n self.model = new AppViewModel();\\n self.valueFromJulia = {};\\n for (var key in json_data) {\\n self.valueFromJulia[key] = false;\\n }\\n ko.applyBindings(self.model, self.dom);\\n}\\n);\\n (WebIO.importBlock({\\\"data\\\":[{\\\"name\\\":\\\"knockout\\\",\\\"type\\\":\\\"js\\\",\\\"url\\\":\\\"/assetserver/800fa077652c804a9c5f68b6c1e29c6c61f85df7-knockout.js\\\"},{\\\"name\\\":\\\"knockout_punches\\\",\\\"type\\\":\\\"js\\\",\\\"url\\\":\\\"/assetserver/81e3f253b58efa296c3c65b00e2bf7b25de6cca9-knockout_punches.js\\\"}],\\\"type\\\":\\\"async_block\\\"})).then((imports) => handler.apply(this, imports));\\n}\\n\")])], Dict{Symbol,Any}(:className => \"field interact-widget\")), Observable{Any} with 0 listeners. Value:\n",
"Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[DataFrameRow. Omitted printing of 8 columns\n",
"│ Row │ province │ country │ Lat │ Long │ 1/22/20 │ 1/23/20 │ 1/24/20 │\n",
"│ │ \u001b[90mString⍰\u001b[39m │ \u001b[90mString\u001b[39m │ \u001b[90mFloat64\u001b[39m │ \u001b[90mFloat64\u001b[39m │ \u001b[90mInt64\u001b[39m │ \u001b[90mInt64\u001b[39m │ \u001b[90mInt64\u001b[39m │\n",
"├─────┼──────────┼─────────┼─────────┼──────────┼─────────┼─────────┼─────────┤\n",
"│ 127 │ \u001b[90mmissing\u001b[39m │ Haiti │ 18.9712 │ -72.2852 │ 0 │ 0 │ 0 │], Dict{Symbol,Any}(:className => \"interact-flex-row interact-widget\"))], Dict{Symbol,Any}())"
]
},
"execution_count": 60,
"metadata": {
"application/vnd.webio.node+json": {
"kernelId": "7ee91d4c-50bd-4f6b-aa33-6303bf7a1e75"
}
},
"output_type": "execute_result"
}
],
"source": [
"@manipulate for i in 1:length(countries)\n",
" data[i, 1:15]\n",
"end"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Extract data and plot"
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"execution_count": 61,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"startswith(\"United\", \"U\")"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"false"
]
},
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"startswith(\"David\", \"U\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Array comprehension:"
]
},
{
"cell_type": "code",
"execution_count": 66,
"metadata": {},
"outputs": [],
"source": [
"U_countries = [startswith(country, \"U\") for country in countries];"
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"province country Lat Long 1/22/20 1/23/20 String⍰ String Float64 Float64 Int64 Int64 16 rows × 72 columns (omitted printing of 66 columns)
1 missing Uganda 1.0 32.0 0 0 2 missing Ukraine 48.3794 31.1656 0 0 3 missing United Arab Emirates 24.0 54.0 0 0 4 Bermuda United Kingdom 32.3078 -64.7505 0 0 5 Cayman Islands United Kingdom 19.3133 -81.2546 0 0 6 Channel Islands United Kingdom 49.3723 -2.3644 0 0 7 Gibraltar United Kingdom 36.1408 -5.3536 0 0 8 Isle of Man United Kingdom 54.2361 -4.5481 0 0 9 Montserrat United Kingdom 16.7425 -62.1874 0 0 10 missing United Kingdom 55.3781 -3.436 0 0 11 missing Uruguay -32.5228 -55.7658 0 0 12 missing US 37.0902 -95.7129 1 1 13 missing Uzbekistan 41.3775 64.5853 0 0 14 Anguilla United Kingdom 18.2206 -63.0686 0 0 15 British Virgin Islands United Kingdom 18.4207 -64.64 0 0 16 Turks and Caicos Islands United Kingdom 21.694 -71.7979 0 0
"
],
"text/latex": [
"\\begin{tabular}{r|ccccccc}\n",
"\t& province & country & Lat & Long & 1/22/20 & 1/23/20 & \\\\\n",
"\t\\hline\n",
"\t& String⍰ & String & Float64 & Float64 & Int64 & Int64 & \\\\\n",
"\t\\hline\n",
"\t1 & & Uganda & 1.0 & 32.0 & 0 & 0 & $\\dots$ \\\\\n",
"\t2 & & Ukraine & 48.3794 & 31.1656 & 0 & 0 & $\\dots$ \\\\\n",
"\t3 & & United Arab Emirates & 24.0 & 54.0 & 0 & 0 & $\\dots$ \\\\\n",
"\t4 & Bermuda & United Kingdom & 32.3078 & -64.7505 & 0 & 0 & $\\dots$ \\\\\n",
"\t5 & Cayman Islands & United Kingdom & 19.3133 & -81.2546 & 0 & 0 & $\\dots$ \\\\\n",
"\t6 & Channel Islands & United Kingdom & 49.3723 & -2.3644 & 0 & 0 & $\\dots$ \\\\\n",
"\t7 & Gibraltar & United Kingdom & 36.1408 & -5.3536 & 0 & 0 & $\\dots$ \\\\\n",
"\t8 & Isle of Man & United Kingdom & 54.2361 & -4.5481 & 0 & 0 & $\\dots$ \\\\\n",
"\t9 & Montserrat & United Kingdom & 16.7425 & -62.1874 & 0 & 0 & $\\dots$ \\\\\n",
"\t10 & & United Kingdom & 55.3781 & -3.436 & 0 & 0 & $\\dots$ \\\\\n",
"\t11 & & Uruguay & -32.5228 & -55.7658 & 0 & 0 & $\\dots$ \\\\\n",
"\t12 & & US & 37.0902 & -95.7129 & 1 & 1 & $\\dots$ \\\\\n",
"\t13 & & Uzbekistan & 41.3775 & 64.5853 & 0 & 0 & $\\dots$ \\\\\n",
"\t14 & Anguilla & United Kingdom & 18.2206 & -63.0686 & 0 & 0 & $\\dots$ \\\\\n",
"\t15 & British Virgin Islands & United Kingdom & 18.4207 & -64.64 & 0 & 0 & $\\dots$ \\\\\n",
"\t16 & Turks and Caicos Islands & United Kingdom & 21.694 & -71.7979 & 0 & 0 & $\\dots$ \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"16×72 DataFrame. Omitted printing of 68 columns\n",
"│ Row │ province │ country │ Lat │ Long │\n",
"│ │ \u001b[90mUnion{Missing, String}\u001b[39m │ \u001b[90mString\u001b[39m │ \u001b[90mFloat64\u001b[39m │ \u001b[90mFloat64\u001b[39m │\n",
"├─────┼──────────────────────────┼──────────────────────┼──────────┼──────────┤\n",
"│ 1 │ \u001b[90mmissing\u001b[39m │ Uganda │ 1.0 │ 32.0 │\n",
"│ 2 │ \u001b[90mmissing\u001b[39m │ Ukraine │ 48.3794 │ 31.1656 │\n",
"│ 3 │ \u001b[90mmissing\u001b[39m │ United Arab Emirates │ 24.0 │ 54.0 │\n",
"│ 4 │ Bermuda │ United Kingdom │ 32.3078 │ -64.7505 │\n",
"│ 5 │ Cayman Islands │ United Kingdom │ 19.3133 │ -81.2546 │\n",
"│ 6 │ Channel Islands │ United Kingdom │ 49.3723 │ -2.3644 │\n",
"│ 7 │ Gibraltar │ United Kingdom │ 36.1408 │ -5.3536 │\n",
"│ 8 │ Isle of Man │ United Kingdom │ 54.2361 │ -4.5481 │\n",
"│ 9 │ Montserrat │ United Kingdom │ 16.7425 │ -62.1874 │\n",
"│ 10 │ \u001b[90mmissing\u001b[39m │ United Kingdom │ 55.3781 │ -3.436 │\n",
"│ 11 │ \u001b[90mmissing\u001b[39m │ Uruguay │ -32.5228 │ -55.7658 │\n",
"│ 12 │ \u001b[90mmissing\u001b[39m │ US │ 37.0902 │ -95.7129 │\n",
"│ 13 │ \u001b[90mmissing\u001b[39m │ Uzbekistan │ 41.3775 │ 64.5853 │\n",
"│ 14 │ Anguilla │ United Kingdom │ 18.2206 │ -63.0686 │\n",
"│ 15 │ British Virgin Islands │ United Kingdom │ 18.4207 │ -64.64 │\n",
"│ 16 │ Turks and Caicos Islands │ United Kingdom │ 21.694 │ -71.7979 │"
]
},
"execution_count": 68,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data[U_countries, :]"
]
},
{
"cell_type": "code",
"execution_count": 69,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"false"
]
},
"execution_count": 69,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"countries == \"US\""
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"253-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": 71,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"countries .== \"US\" \n",
"# . is \"broadcasting\": apply operation to each element of a vector"
]
},
{
"cell_type": "code",
"execution_count": 75,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"226"
]
},
"execution_count": 75,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"US_row = findfirst(countries .== \"US\")"
]
},
{
"cell_type": "code",
"execution_count": 77,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"DataFrameRow (72 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 226 missing US 37.0902 -95.7129 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",
"\t226 & & US & 37.0902 & -95.7129 & 1 & 1 & 2 & 2 & 5 & $\\dots$ \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"DataFrameRow. Omitted printing of 65 columns\n",
"│ Row │ province │ country │ Lat │ Long │ 1/22/20 │ 1/23/20 │ 1/24/20 │\n",
"│ │ \u001b[90mString⍰\u001b[39m │ \u001b[90mString\u001b[39m │ \u001b[90mFloat64\u001b[39m │ \u001b[90mFloat64\u001b[39m │ \u001b[90mInt64\u001b[39m │ \u001b[90mInt64\u001b[39m │ \u001b[90mInt64\u001b[39m │\n",
"├─────┼──────────┼─────────┼─────────┼──────────┼─────────┼─────────┼─────────┤\n",
"│ 226 │ \u001b[90mmissing\u001b[39m │ US │ 37.0902 │ -95.7129 │ 1 │ 1 │ 2 │"
]
},
"execution_count": 77,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"US_data_row = data[US_row, :]"
]
},
{
"cell_type": "code",
"execution_count": 78,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"68-element Array{Int64,1}:\n",
" 1\n",
" 1\n",
" 2\n",
" 2\n",
" 5\n",
" 5\n",
" 5\n",
" 5\n",
" 5\n",
" 7\n",
" 8\n",
" 8\n",
" 11\n",
" ⋮\n",
" 7783\n",
" 13677\n",
" 19100\n",
" 25489\n",
" 33276\n",
" 43847\n",
" 53740\n",
" 65778\n",
" 83836\n",
" 101657\n",
" 121478\n",
" 140886"
]
},
"execution_count": 78,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"US_data = convert(Vector, US_data_row[5:end])"
]
},
{
"cell_type": "code",
"execution_count": 79,
"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": 80,
"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",
"0 \n",
" \n",
"\n",
"20 \n",
" \n",
"\n",
"40 \n",
" \n",
"\n",
"60 \n",
" \n",
"\n",
"0 \n",
" \n",
"\n",
"2.50×10 \n",
" \n",
"\n",
"4 \n",
" \n",
"\n",
"5.00×10 \n",
" \n",
"\n",
"4 \n",
" \n",
"\n",
"7.50×10 \n",
" \n",
"\n",
"4 \n",
" \n",
"\n",
"1.00×10 \n",
" \n",
"\n",
"5 \n",
" \n",
"\n",
"1.25×10 \n",
" \n",
"\n",
"5 \n",
" \n",
" \n",
"\n",
" \n",
" \n",
"\n",
"y1 \n",
" \n",
" \n"
]
},
"execution_count": 80,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(US_data)"
]
},
{
"cell_type": "code",
"execution_count": 84,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"72-element Array{Symbol,1}:\n",
" :province\n",
" :country\n",
" :Lat\n",
" :Long\n",
" Symbol(\"1/22/20\")\n",
" Symbol(\"1/23/20\")\n",
" Symbol(\"1/24/20\")\n",
" Symbol(\"1/25/20\")\n",
" Symbol(\"1/26/20\")\n",
" Symbol(\"1/27/20\")\n",
" Symbol(\"1/28/20\")\n",
" Symbol(\"1/29/20\")\n",
" Symbol(\"1/30/20\")\n",
" ⋮\n",
" Symbol(\"3/18/20\")\n",
" Symbol(\"3/19/20\")\n",
" Symbol(\"3/20/20\")\n",
" Symbol(\"3/21/20\")\n",
" Symbol(\"3/22/20\")\n",
" Symbol(\"3/23/20\")\n",
" Symbol(\"3/24/20\")\n",
" Symbol(\"3/25/20\")\n",
" Symbol(\"3/26/20\")\n",
" Symbol(\"3/27/20\")\n",
" Symbol(\"3/28/20\")\n",
" Symbol(\"3/29/20\")"
]
},
"execution_count": 84,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"col_names = names(data)"
]
},
{
"cell_type": "code",
"execution_count": 90,
"metadata": {},
"outputs": [],
"source": [
"date_strings = String.(names(data))[5:end]; # apply String function to each element"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Parse: convert string representation into a Julia object:"
]
},
{
"cell_type": "code",
"execution_count": 91,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"1/22/20\""
]
},
"execution_count": 91,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"date_strings[1]"
]
},
{
"cell_type": "code",
"execution_count": 92,
"metadata": {},
"outputs": [],
"source": [
"using Dates"
]
},
{
"cell_type": "code",
"execution_count": 94,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dateformat\"d/m/Y\""
]
},
"execution_count": 94,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"format = Dates.DateFormat(\"d/m/Y\")"
]
},
{
"cell_type": "code",
"execution_count": 95,
"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 /Users/julia/buildbot/worker/package_macos64/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 /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Dates/src/parse.jl:285",
" [3] top-level scope at In[95]:1"
]
}
],
"source": [
"parse(Date, date_strings[1], format)"
]
},
{
"cell_type": "code",
"execution_count": 96,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dateformat\"m/d/Y\""
]
},
"execution_count": 96,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"format = Dates.DateFormat(\"m/d/Y\")"
]
},
{
"cell_type": "code",
"execution_count": 98,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2020-01-22"
]
},
"execution_count": 98,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"parse(Date, date_strings[1], format) + Year(2000)"
]
},
{
"cell_type": "code",
"execution_count": 99,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"68-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-03-18\n",
" 2020-03-19\n",
" 2020-03-20\n",
" 2020-03-21\n",
" 2020-03-22\n",
" 2020-03-23\n",
" 2020-03-24\n",
" 2020-03-25\n",
" 2020-03-26\n",
" 2020-03-27\n",
" 2020-03-28\n",
" 2020-03-29"
]
},
"execution_count": 99,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dates = parse.(Date, date_strings, format) .+ Year(2000)"
]
},
{
"cell_type": "code",
"execution_count": 110,
"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",
"2020-01-22 \n",
" \n",
"\n",
"2020-01-27 \n",
" \n",
"\n",
"2020-02-01 \n",
" \n",
"\n",
"2020-02-06 \n",
" \n",
"\n",
"2020-02-11 \n",
" \n",
"\n",
"2020-02-16 \n",
" \n",
"\n",
"2020-02-21 \n",
" \n",
"\n",
"2020-02-26 \n",
" \n",
"\n",
"2020-03-02 \n",
" \n",
"\n",
"2020-03-07 \n",
" \n",
"\n",
"2020-03-12 \n",
" \n",
"\n",
"2020-03-17 \n",
" \n",
"\n",
"2020-03-22 \n",
" \n",
"\n",
"2020-03-27 \n",
" \n",
"\n",
"0 \n",
" \n",
"\n",
"2.50×10 \n",
" \n",
"\n",
"4 \n",
" \n",
"\n",
"5.00×10 \n",
" \n",
"\n",
"4 \n",
" \n",
"\n",
"7.50×10 \n",
" \n",
"\n",
"4 \n",
" \n",
"\n",
"1.00×10 \n",
" \n",
"\n",
"5 \n",
" \n",
"\n",
"1.25×10 \n",
" \n",
"\n",
"5 \n",
" \n",
"\n",
"US confirmed COVID-19 cases \n",
" \n",
"\n",
"date \n",
" \n",
"\n",
"confirmed cases in US \n",
" \n",
" \n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"US data \n",
" \n",
"\n",
"US \n",
" \n",
" \n"
]
},
"execution_count": 110,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(dates, US_data, xticks=dates[1:5:end], xrotation=45, leg=:topleft, \n",
" label=\"US data\", m=:o)\n",
"\n",
"xlabel!(\"date\")\n",
"ylabel!(\"confirmed cases in US\")\n",
"title!(\"US confirmed COVID-19 cases\")\n",
"\n",
"# annotate!(20, US_data[end], text(\"US\", :blue, :left))"
]
},
{
"cell_type": "code",
"execution_count": 111,
"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",
"2020-01-22 \n",
" \n",
"\n",
"2020-01-27 \n",
" \n",
"\n",
"2020-02-01 \n",
" \n",
"\n",
"2020-02-06 \n",
" \n",
"\n",
"2020-02-11 \n",
" \n",
"\n",
"2020-02-16 \n",
" \n",
"\n",
"2020-02-21 \n",
" \n",
"\n",
"2020-02-26 \n",
" \n",
"\n",
"2020-03-02 \n",
" \n",
"\n",
"2020-03-07 \n",
" \n",
"\n",
"2020-03-12 \n",
" \n",
"\n",
"2020-03-17 \n",
" \n",
"\n",
"2020-03-22 \n",
" \n",
"\n",
"2020-03-27 \n",
" \n",
"\n",
"10 \n",
" \n",
"\n",
"0 \n",
" \n",
"\n",
"10 \n",
" \n",
"\n",
"1 \n",
" \n",
"\n",
"10 \n",
" \n",
"\n",
"2 \n",
" \n",
"\n",
"10 \n",
" \n",
"\n",
"3 \n",
" \n",
"\n",
"10 \n",
" \n",
"\n",
"4 \n",
" \n",
"\n",
"10 \n",
" \n",
"\n",
"5 \n",
" \n",
"\n",
"US confirmed COVID-19 cases \n",
" \n",
"\n",
"date \n",
" \n",
"\n",
"confirmed cases in US \n",
" \n",
" \n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
"\n",
"US data \n",
" \n",
" \n"
]
},
"execution_count": 111,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(dates, US_data, xticks=dates[1:5:end], xrotation=45, leg=:topleft, \n",
" label=\"US data\", m=:o,\n",
" yscale=:log10)\n",
"\n",
"xlabel!(\"date\")\n",
"ylabel!(\"confirmed cases in US\")\n",
"title!(\"US confirmed COVID-19 cases\")\n",
"\n",
"# annotate!(20, US_data[end], text(\"US\", :blue, :left))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Straight line on semi-log scale means **exponential growth**!"
]
},
{
"cell_type": "code",
"execution_count": 114,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"f (generic function with 1 method)"
]
},
"execution_count": 114,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function f(country)\n",
" return country * country\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 115,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"USUS\""
]
},
"execution_count": 115,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f(\"US\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`plot!` add new curve onto the same graph\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"@webio": {
"lastCommId": "8bf6c35eb9434a1381c3e081ee78ba70",
"lastKernelId": "bdbfbf2c-a906-45ec-b466-7c67e4869cc5"
},
"kernelspec": {
"display_name": "Julia 1.4.0",
"language": "julia",
"name": "julia-1.4"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.4.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}