Skip to content
Snippets Groups Projects
covidtracking-dashboard.ipynb 69.8 KiB
Newer Older
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 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import altair as alt\n",
    "from IPython.display import display, HTML"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "html_credits=HTML('''\n",
    "<p style=\"font-size: smaller\">Data Sources: \n",
    "  <a href=\"https://covidtracking.com\">The COVID Tracking Project</a>\n",
    "<br>\n",
    "Analysis and Visualization:\n",
    "  <a href=\"https://renkulab.io/projects/covid-19/covid-19-public-data\">Covid-19 Public Data Collaboration Project</a>\n",
    "</p>''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Read population data\n",
    "pop_df = pd.read_csv('../data/geodata/us_pop_fung_2019.csv').set_index('ST')\n",
    "\n",
    "# Read state-level data\n",
    "data_df = pd.read_json('../data/covidtracking/states-daily.json')\n",
    "data_df['date'] = pd.to_datetime(data_df['date'], format=\"%Y%m%d\")\n",
    "data_df['ratio'] = data_df['positive']/data_df['total']\n",
    "\n",
    "# Compute daily differences\n",
    "tdf = data_df.sort_values(['state', 'date'], ascending=[True, False]).set_index(['state', 'date'])\n",
    "diffs_df = tdf[['positive', 'negative', 'death']].groupby(level='state').diff(periods=-1).dropna(how='all')\n",
    "tdf_diff=tdf.join(diffs_df, rsuffix='_diff').reset_index()\n",
    "\n",
    "# incidence rates\n",
    "tdf_diff = tdf_diff.set_index('state')\n",
    "tdf_diff['positive_diff_100k'] = (tdf_diff['positive_diff'] / pop_df['Population']) * 100000\n",
    "tdf_diff['death_diff_100k'] = (tdf_diff['death_diff'] / pop_df['Population']) * 100000\n",
    "tdf_diff = tdf_diff.reset_index()\n",
    "\n",
    "# \"Normalizing\" the totals\n",
    "tdf_diff['total_10'] = tdf_diff['total']/10.\n",
    "\n",
    "# Daily totals\n",
    "daily_totals = tdf_diff.groupby('date').sum()\n",
    "daily_totals.reset_index(level=0, inplace=True)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Covid-19 Cases in U.S.\n",
    "\n",
    "The case data from the U.S. is obtained from https://covidtracking.com, a public crowd-sourced covid-19 dataset. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Daily Cumulative Totals\n",
    "\n",
    "Cumulative reported totals of positive cases and deaths. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<div id=\"altair-viz-691fa71f9255408f94dbe2b011bf6092\"></div>\n",
       "<script type=\"text/javascript\">\n",
       "  (function(spec, embedOpt){\n",
       "    const outputDiv = document.getElementById(\"altair-viz-691fa71f9255408f94dbe2b011bf6092\");\n",
       "    const paths = {\n",
       "      \"vega\": \"https://cdn.jsdelivr.net/npm//vega@5?noext\",\n",
       "      \"vega-lib\": \"https://cdn.jsdelivr.net/npm//vega-lib?noext\",\n",
       "      \"vega-lite\": \"https://cdn.jsdelivr.net/npm//vega-lite@4.0.2?noext\",\n",
       "      \"vega-embed\": \"https://cdn.jsdelivr.net/npm//vega-embed@6?noext\",\n",
       "    };\n",
       "\n",
       "    function loadScript(lib) {\n",
       "      return new Promise(function(resolve, reject) {\n",
       "        var s = document.createElement('script');\n",
       "        s.src = paths[lib];\n",
       "        s.async = true;\n",
       "        s.onload = () => resolve(paths[lib]);\n",
       "        s.onerror = () => reject(`Error loading script: ${paths[lib]}`);\n",
       "        document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "      });\n",
       "    }\n",
       "\n",
       "    function showError(err) {\n",
       "      outputDiv.innerHTML = `<div class=\"error\" style=\"color:red;\">${err}</div>`;\n",
       "      throw err;\n",
       "    }\n",
       "\n",
       "    function displayChart(vegaEmbed) {\n",
       "      vegaEmbed(outputDiv, spec, embedOpt)\n",
       "        .catch(err => showError(`Javascript Error: ${err.message}<br>This usually means there's a typo in your chart specification. See the javascript console for the full traceback.`));\n",
       "    }\n",
       "\n",
       "    if(typeof define === \"function\" && define.amd) {\n",
       "      requirejs.config({paths});\n",
       "      require([\"vega-embed\"], displayChart, err => showError(`Error loading script: ${err.message}`));\n",
       "    } else if (typeof vegaEmbed === \"function\") {\n",
       "      displayChart(vegaEmbed);\n",
       "    } else {\n",
       "      loadScript(\"vega\")\n",
       "        .then(() => loadScript(\"vega-lite\"))\n",
       "        .then(() => loadScript(\"vega-embed\"))\n",
       "        .catch(showError)\n",
       "        .then(() => displayChart(vegaEmbed));\n",
       "    }\n",
       "  })({\"config\": {\"view\": {\"continuousWidth\": 400, \"continuousHeight\": 300}, \"title\": {\"anchor\": \"middle\"}}, \"vconcat\": [{\"hconcat\": [{\"mark\": {\"type\": \"bar\", \"size\": 15}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"field\": \"positive\", \"title\": \"Cumulative cases\"}}}, {\"mark\": {\"type\": \"bar\", \"size\": 15}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"field\": \"positive_diff\", \"title\": \"Daily cases\"}}}]}, {\"hconcat\": [{\"mark\": {\"type\": \"bar\", \"size\": 15}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"field\": \"death\", \"title\": \"Cumulative deaths\"}}}, {\"mark\": {\"type\": \"bar\", \"size\": 15}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"field\": \"death_diff\", \"title\": \"Daily deaths\"}}}]}], \"data\": {\"name\": \"data-51e9b342ddbb318e3b8f6134efc9291b\"}, \"title\": \"Cumulative Covid-19 cases in the U.S.\", \"$schema\": \"https://vega.github.io/schema/vega-lite/v4.0.2.json\", \"datasets\": {\"data-51e9b342ddbb318e3b8f6134efc9291b\": [{\"date\": \"2020-03-04T00:00:00\", \"positive\": 118.0, \"negative\": 748.0, \"pending\": 103.0, \"hospitalized\": 0.0, \"death\": 0.0, \"total\": 969, \"ratio\": 5.515809423282292, \"positive_diff\": 0.0, \"negative_diff\": 0.0, \"death_diff\": 0.0, \"positive_diff_100k\": 0.0, \"death_diff_100k\": 0.0, \"total_10\": 96.9}, {\"date\": \"2020-03-05T00:00:00\", \"positive\": 176.0, \"negative\": 953.0, \"pending\": 197.0, \"hospitalized\": 0.0, \"death\": 0.0, \"total\": 1326, \"ratio\": 7.691963187672735, \"positive_diff\": 55.0, \"negative_diff\": 99.0, \"death_diff\": 0.0, \"positive_diff_100k\": 0.5298275537038083, \"death_diff_100k\": 0.0, \"total_10\": 132.59999999999997}, {\"date\": \"2020-03-06T00:00:00\", \"positive\": 223.0, \"negative\": 1571.0, \"pending\": 458.0, \"hospitalized\": 0.0, \"death\": 0.0, \"total\": 2252, \"ratio\": 8.84189813481705, \"positive_diff\": 44.0, \"negative_diff\": 137.0, \"death_diff\": 0.0, \"positive_diff_100k\": 0.4002079423948694, \"death_diff_100k\": 0.0, \"total_10\": 225.2}, {\"date\": \"2020-03-07T00:00:00\", \"positive\": 341.0, \"negative\": 1809.0, \"pending\": 602.0, \"hospitalized\": 0.0, \"death\": 0.0, \"total\": 2752, \"ratio\": 13.209662158531827, \"positive_diff\": 113.0, \"negative_diff\": 194.0, \"death_diff\": 0.0, \"positive_diff_100k\": 1.0879306092476013, \"death_diff_100k\": 0.0, \"total_10\": 275.2}, {\"date\": \"2020-03-08T00:00:00\", \"positive\": 417.0, \"negative\": 2335.0, \"pending\": 347.0, \"hospitalized\": 0.0, \"death\": 0.0, \"total\": 3099, \"ratio\": 12.32417291309689, \"positive_diff\": 76.0, \"negative_diff\": 423.0, \"death_diff\": 0.0, \"positive_diff_100k\": 1.114311671083663, \"death_diff_100k\": 0.0, \"total_10\": 309.9}, {\"date\": \"2020-03-09T00:00:00\", \"positive\": 584.0, \"negative\": 3367.0, \"pending\": 313.0, \"hospitalized\": 0.0, \"death\": 0.0, \"total\": 4264, \"ratio\": 12.85071660526928, \"positive_diff\": 167.0, \"negative_diff\": 1032.0, \"death_diff\": 0.0, \"positive_diff_100k\": 1.8189942831236092, \"death_diff_100k\": 0.0, \"total_10\": 426.3999999999999}, {\"date\": \"2020-03-10T00:00:00\", \"positive\": 778.0, \"negative\": 3807.0, \"pending\": 469.0, \"hospitalized\": 0.0, \"death\": 0.0, \"total\": 5054, \"ratio\": 12.154127882707202, \"positive_diff\": 194.0, \"negative_diff\": 410.0, \"death_diff\": 0.0, \"positive_diff_100k\": 2.7039844813891034, \"death_diff_100k\": 0.0, \"total_10\": 505.4}, {\"date\": \"2020-03-11T00:00:00\", \"positive\": 1053.0, \"negative\": 5978.0, \"pending\": 563.0, \"hospitalized\": 0.0, \"death\": 27.0, \"total\": 7617, \"ratio\": 11.208808989767583, \"positive_diff\": 275.0, \"negative_diff\": 2105.0, \"death_diff\": 0.0, \"positive_diff_100k\": 4.019334743734134, \"death_diff_100k\": 0.0, \"total_10\": 761.7}, {\"date\": \"2020-03-12T00:00:00\", \"positive\": 1315.0, \"negative\": 7949.0, \"pending\": 673.0, \"hospitalized\": 0.0, \"death\": 36.0, \"total\": 9966, \"ratio\": 10.054505630227366, \"positive_diff\": 262.0, \"negative_diff\": 1716.0, \"death_diff\": 5.0, \"positive_diff_100k\": 5.624305797598059, \"death_diff_100k\": 0.06566080442627362, \"total_10\": 996.6}, {\"date\": \"2020-03-13T00:00:00\", \"positive\": 1922.0, \"negative\": 13613.0, \"pending\": 1130.0, \"hospitalized\": 0.0, \"death\": 39.0, \"total\": 16665, \"ratio\": 9.175450650028257, \"positive_diff\": 607.0, \"negative_diff\": 2793.0, \"death_diff\": 2.0, \"positive_diff_100k\": 8.020087301519814, \"death_diff_100k\": 0.026264321770509448, \"total_10\": 1666.5000000000005}, {\"date\": \"2020-03-14T00:00:00\", \"positive\": 2450.0, \"negative\": 17102.0, \"pending\": 1236.0, \"hospitalized\": 0.0, \"death\": 49.0, \"total\": 20789, \"ratio\": 8.811365861432826, \"positive_diff\": 528.0, \"negative_diff\": 3489.0, \"death_diff\": 8.0, \"positive_diff_100k\": 7.522230821043739, \"death_diff_100k\": 0.08597981173139377, \"total_10\": 2078.9}, {\"date\": \"2020-03-15T00:00:00\", \"positive\": 3173.0, \"negative\": 22548.0, \"pending\": 2242.0, \"hospitalized\": 0.0, \"death\": 60.0, \"total\": 27963, \"ratio\": 9.136862838236842, \"positive_diff\": 723.0, \"negative_diff\": 5446.0, \"death_diff\": 5.0, \"positive_diff_100k\": 9.736170827916586, \"death_diff_100k\": 0.05531095133927636, \"total_10\": 2796.3}, {\"date\": \"2020-03-16T00:00:00\", \"positive\": 4019.0, \"negative\": 36104.0, \"pending\": 1691.0, \"hospitalized\": 0.0, \"death\": 71.0, \"total\": 41714, \"ratio\": 11.220932181161599, \"positive_diff\": 837.0, \"negative_diff\": 13524.0, \"death_diff\": 8.0, \"positive_diff_100k\": 12.105280688881605, \"death_diff_100k\": 0.06421091573267143, \"total_10\": 4171.400000000001}, {\"date\": \"2020-03-17T00:00:00\", \"positive\": 5723.0, \"negative\": 47604.0, \"pending\": 1687.0, \"hospitalized\": 0.0, \"death\": 90.0, \"total\": 54957, \"ratio\": 9.740374437510395, \"positive_diff\": 1704.0, \"negative_diff\": 10201.0, \"death_diff\": 17.0, \"positive_diff_100k\": 20.726028204722564, \"death_diff_100k\": 0.16989358409385108, \"total_10\": 5495.699999999999}, {\"date\": \"2020-03-18T00:00:00\", \"positive\": 7731.0, \"negative\": 66225.0, \"pending\": 2538.0, \"hospitalized\": 0.0, \"death\": 112.0, \"total\": 76495, \"ratio\": 8.606556459953612, \"positive_diff\": 2008.0, \"negative_diff\": 17217.0, \"death_diff\": 18.0, \"positive_diff_100k\": 27.530078336913014, \"death_diff_100k\": 0.1743011549896832, \"total_10\": 7649.499999999999}, {\"date\": \"2020-03-19T00:00:00\", \"positive\": 11723.0, \"negative\": 89119.0, \"pending\": 3025.0, \"hospitalized\": 0.0, \"death\": 160.0, \"total\": 103867, \"ratio\": 8.456727153467822, \"positive_diff\": 3992.0, \"negative_diff\": 22894.0, \"death_diff\": 41.0, \"positive_diff_100k\": 41.05592023137221, \"death_diff_100k\": 0.4291152914332691, \"total_10\": 10386.7}, {\"date\": \"2020-03-20T00:00:00\", \"positive\": 17038.0, \"negative\": 118147.0, \"pending\": 3336.0, \"hospitalized\": 0.0, \"death\": 219.0, \"total\": 138521, \"ratio\": 8.865717119784163, \"positive_diff\": 5315.0, \"negative_diff\": 29028.0, \"death_diff\": 51.0, \"positive_diff_100k\": 59.019736282820595, \"death_diff_100k\": 0.6044213757021897, \"total_10\": 13852.100000000002}, {\"date\": \"2020-03-21T00:00:00\", \"positive\": 23203.0, \"negative\": 155909.0, \"pending\": 3477.0, \"hospitalized\": 1964.0, \"death\": 272.0, \"total\": 182589, \"ratio\": 8.860167677919787, \"positive_diff\": 6165.0, \"negative_diff\": 37762.0, \"death_diff\": 52.0, \"positive_diff_100k\": 60.68561036861707, \"death_diff_100k\": 0.6328191310140254, \"total_10\": 18258.9}, {\"date\": \"2020-03-22T00:00:00\", \"positive\": 31888.0, \"negative\": 193463.0, \"pending\": 2842.0, \"hospitalized\": 2554.0, \"death\": 398.0, \"total\": 228216, \"ratio\": 8.6820236929459, \"positive_diff\": 8685.0, \"negative_diff\": 37554.0, \"death_diff\": 125.0, \"positive_diff_100k\": 90.83601730037192, \"death_diff_100k\": 1.1021669130972207, \"total_10\": 22821.59999999999}, {\"date\": \"2020-03-23T00:00:00\", \"positive\": 42164.0, \"negative\": 237321.0, \"pending\": 14571.0, \"hospitalized\": 3325.0, \"death\": 471.0, \"total\": 294056, \"ratio\": 9.16638131274229, \"positive_diff\": 10276.0, \"negative_diff\": 43858.0, \"death_diff\": 69.0, \"positive_diff_100k\": 104.21967277706064, \"death_diff_100k\": 1.6099082141188321, \"total_10\": 29405.60000000001}]}}, {\"mode\": \"vega-lite\"});\n",
       "</script>"
      ],
      "text/plain": [
       "alt.VConcatChart(...)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<p style=\"font-size: smaller\">Data Sources: \n",
       "  <a href=\"https://covidtracking.com\">The COVID Tracking Project</a>\n",
       "<br>\n",
       "Analysis and Visualization:\n",
       "  <a href=\"https://renkulab.io/projects/covid-19/covid-19-public-data\">Covid-19 Public Data Collaboration Project</a>\n",
       "</p>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "base = alt.Chart(\n",
    "    daily_totals\n",
    ").mark_bar(size=15).encode(\n",
    "    alt.X('date', axis=alt.Axis(title='')\n",
    "    )\n",
    ")\n",
    "\n",
    "cumulative = base.encode(alt.Y('positive', title = 'Cumulative cases'))\n",
    "cumulative_deaths = base.encode(alt.Y('death', title = 'Cumulative deaths'))\n",
    "rates = base.encode(alt.Y('positive_diff', title='Daily cases'))\n",
    "rates_deaths = base.encode(alt.Y('death_diff', title='Daily deaths'))\n",
    "chart = alt.vconcat(\n",
    "    cumulative | rates, cumulative_deaths | rates_deaths,\n",
    "    title='Cumulative Covid-19 cases in the U.S.'\n",
    ").configure_title(\n",
    "    anchor='middle'\n",
    ")\n",
    "display(chart)\n",
    "display(html_credits)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Total tests and positives per 100k population"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Most recent test date 2020-03-23 00:00:00\n",
      "56 states/territories have data on this date.\n"
     ]
    }
   ],
   "source": [
    "most_recent_test_date = data_df['date'].max()\n",
    "most_recent_df = data_df[data_df['date'] == most_recent_test_date].set_index('state')\n",
    "print(\"Most recent test date\", most_recent_test_date)\n",
    "print(len(most_recent_df), \"states/territories have data on this date.\")\n",
    "\n",
    "most_recent_df['total/100k'] = (most_recent_df['total'] / pop_df['Population']) * 100000\n",
    "most_recent_df['positive/100k'] = (most_recent_df['positive'] / pop_df['Population']) * 100000\n",
    "most_recent_df = most_recent_df.reset_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<div id=\"altair-viz-7d4a7392cfa545fba3047b2785ea2876\"></div>\n",
       "<script type=\"text/javascript\">\n",
       "  (function(spec, embedOpt){\n",
       "    const outputDiv = document.getElementById(\"altair-viz-7d4a7392cfa545fba3047b2785ea2876\");\n",
       "    const paths = {\n",
       "      \"vega\": \"https://cdn.jsdelivr.net/npm//vega@5?noext\",\n",
       "      \"vega-lib\": \"https://cdn.jsdelivr.net/npm//vega-lib?noext\",\n",
       "      \"vega-lite\": \"https://cdn.jsdelivr.net/npm//vega-lite@4.0.2?noext\",\n",
       "      \"vega-embed\": \"https://cdn.jsdelivr.net/npm//vega-embed@6?noext\",\n",
       "    };\n",
       "\n",
       "    function loadScript(lib) {\n",
       "      return new Promise(function(resolve, reject) {\n",
       "        var s = document.createElement('script');\n",
       "        s.src = paths[lib];\n",
       "        s.async = true;\n",
       "        s.onload = () => resolve(paths[lib]);\n",
       "        s.onerror = () => reject(`Error loading script: ${paths[lib]}`);\n",
       "        document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "      });\n",
       "    }\n",
       "\n",
       "    function showError(err) {\n",
       "      outputDiv.innerHTML = `<div class=\"error\" style=\"color:red;\">${err}</div>`;\n",
       "      throw err;\n",
       "    }\n",
       "\n",
       "    function displayChart(vegaEmbed) {\n",
       "      vegaEmbed(outputDiv, spec, embedOpt)\n",
       "        .catch(err => showError(`Javascript Error: ${err.message}<br>This usually means there's a typo in your chart specification. See the javascript console for the full traceback.`));\n",
       "    }\n",
       "\n",
       "    if(typeof define === \"function\" && define.amd) {\n",
       "      requirejs.config({paths});\n",
       "      require([\"vega-embed\"], displayChart, err => showError(`Error loading script: ${err.message}`));\n",
       "    } else if (typeof vegaEmbed === \"function\") {\n",
       "      displayChart(vegaEmbed);\n",
       "    } else {\n",
       "      loadScript(\"vega\")\n",
       "        .then(() => loadScript(\"vega-lite\"))\n",
       "        .then(() => loadScript(\"vega-embed\"))\n",
       "        .catch(showError)\n",
       "        .then(() => displayChart(vegaEmbed));\n",
       "    }\n",
       "  })({\"config\": {\"view\": {\"continuousWidth\": 400, \"continuousHeight\": 300}}, \"layer\": [{\"mark\": \"bar\", \"encoding\": {\"x\": {\"type\": \"nominal\", \"field\": \"state\", \"sort\": null}, \"y\": {\"type\": \"quantitative\", \"field\": \"total/100k\"}}, \"title\": \"Cases per 100k\"}, {\"mark\": {\"type\": \"point\", \"color\": \"orange\", \"filled\": true, \"opacity\": 1, \"size\": 100}, \"encoding\": {\"x\": {\"type\": \"nominal\", \"field\": \"state\", \"sort\": null}, \"y\": {\"type\": \"quantitative\", \"field\": \"positive/100k\"}}, \"title\": \"Cases per 100k\"}], \"data\": {\"name\": \"data-f62451cfd43e9833a710e7269b72bd22\"}, \"$schema\": \"https://vega.github.io/schema/vega-lite/v4.0.2.json\", \"datasets\": {\"data-f62451cfd43e9833a710e7269b72bd22\": [{\"state\": \"OH\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 442.0, \"negative\": 140.0, \"pending\": null, \"hospitalized\": 104.0, \"death\": 6.0, \"total\": 582, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.7594501718213058, \"total/100k\": 4.9789975276111935, \"positive/100k\": 3.7813005278421774}, {\"state\": \"MD\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 288.0, \"negative\": 94.0, \"pending\": null, \"hospitalized\": null, \"death\": 3.0, \"total\": 382, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.7539267015706806, \"total/100k\": 6.3185613528999225, \"positive/100k\": 4.763732119463815}, {\"state\": \"AZ\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 265.0, \"negative\": 309.0, \"pending\": 6.0, \"hospitalized\": null, \"death\": 2.0, \"total\": 580, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.45689655172413796, \"total/100k\": 7.9684372946495925, \"positive/100k\": 3.6407515225554175}, {\"state\": \"MO\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 183.0, \"negative\": 369.0, \"pending\": null, \"hospitalized\": null, \"death\": 3.0, \"total\": 552, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.33152173913043476, \"total/100k\": 8.993995530375264, \"positive/100k\": 2.981705039961365}, {\"state\": \"DE\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 68.0, \"negative\": 36.0, \"pending\": null, \"hospitalized\": 0.0, \"death\": 0.0, \"total\": 104, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.6538461538461539, \"total/100k\": 10.680205881507224, \"positive/100k\": 6.98321153790857}, {\"state\": \"KS\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 82.0, \"negative\": 417.0, \"pending\": null, \"hospitalized\": null, \"death\": 2.0, \"total\": 499, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.16432865731462926, \"total/100k\": 17.12826011888866, \"positive/100k\": 2.8146639874726858}, {\"state\": \"NE\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 50.0, \"negative\": 356.0, \"pending\": null, \"hospitalized\": null, \"death\": 0.0, \"total\": 406, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.12315270935960591, \"total/100k\": 20.988333381582375, \"positive/100k\": 2.584770120884529}, {\"state\": \"OK\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 81.0, \"negative\": 694.0, \"pending\": 102.0, \"hospitalized\": 15.0, \"death\": 2.0, \"total\": 877, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.09236031927023945, \"total/100k\": 22.163417422063493, \"positive/100k\": 2.0470203092213715}, {\"state\": \"WV\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 16.0, \"negative\": 444.0, \"pending\": 4.0, \"hospitalized\": 1.0, \"death\": 0.0, \"total\": 464, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.034482758620689655, \"total/100k\": 25.963169230063336, \"positive/100k\": 0.8952816975883908}, {\"state\": \"IN\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 259.0, \"negative\": 1701.0, \"pending\": null, \"hospitalized\": 1.0, \"death\": 7.0, \"total\": 1960, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.13214285714285715, \"total/100k\": 29.113729069122673, \"positive/100k\": 3.8471713412769253}, {\"state\": \"MI\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 1328.0, \"negative\": 2069.0, \"pending\": null, \"hospitalized\": null, \"death\": 15.0, \"total\": 3397, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.3909331763320577, \"total/100k\": 34.01470552747476, \"positive/100k\": 13.297476873855308}, {\"state\": \"SC\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 299.0, \"negative\": 1466.0, \"pending\": null, \"hospitalized\": null, \"death\": 5.0, \"total\": 1765, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.16940509915014165, \"total/100k\": 34.28040477680446, \"positive/100k\": 5.807275370121549}, {\"state\": \"TX\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 352.0, \"negative\": 9703.0, \"pending\": null, \"hospitalized\": null, \"death\": 8.0, \"total\": 10055, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.035007458975634016, \"total/100k\": 34.67733917103605, \"positive/100k\": 1.213965528414191}, {\"state\": \"AR\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 174.0, \"negative\": 906.0, \"pending\": 0.0, \"hospitalized\": 13.0, \"death\": 0.0, \"total\": 1080, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.16111111111111112, \"total/100k\": 35.78736341570502, \"positive/100k\": 5.765741883641365}, {\"state\": \"NJ\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 2844.0, \"negative\": 359.0, \"pending\": 94.0, \"hospitalized\": null, \"death\": 27.0, \"total\": 3297, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.8626023657870792, \"total/100k\": 37.11922397516829, \"positive/100k\": 32.01913041716063}, {\"state\": \"AL\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 167.0, \"negative\": 1665.0, \"pending\": null, \"hospitalized\": null, \"death\": 0.0, \"total\": 1832, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.09115720524017468, \"total/100k\": 37.36346884729008, \"positive/100k\": 3.4059493981972944}, {\"state\": \"KY\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 104.0, \"negative\": 1762.0, \"pending\": null, \"hospitalized\": null, \"death\": 3.0, \"total\": 1866, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.055734190782422297, \"total/100k\": 41.76670942568984, \"positive/100k\": 2.327833751485393}, {\"state\": \"VA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 254.0, \"negative\": 3443.0, \"pending\": null, \"hospitalized\": 38.0, \"death\": 6.0, \"total\": 3697, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.06870435488233703, \"total/100k\": 43.31312483751721, \"positive/100k\": 2.975800299899748}, {\"state\": \"MS\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 249.0, \"negative\": 1143.0, \"pending\": null, \"hospitalized\": 33.0, \"death\": 1.0, \"total\": 1392, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.1788793103448276, \"total/100k\": 46.77185181252686, \"positive/100k\": 8.366516595775279}, {\"state\": \"GA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 772.0, \"negative\": 4297.0, \"pending\": null, \"hospitalized\": null, \"death\": 25.0, \"total\": 5069, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.152298283685145, \"total/100k\": 47.7422817193965, \"positive/100k\": 7.271067565076761}, {\"state\": \"PA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 644.0, \"negative\": 6595.0, \"pending\": null, \"hospitalized\": null, \"death\": 6.0, \"total\": 7239, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.08896256389004006, \"total/100k\": 56.545900797133946, \"positive/100k\": 5.030468312384896}, {\"state\": \"TN\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 615.0, \"negative\": 3272.0, \"pending\": null, \"hospitalized\": null, \"death\": 2.0, \"total\": 3887, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.15821970671469, \"total/100k\": 56.8842532035625, \"positive/100k\": 9.000209858551823}, {\"state\": \"FL\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 1171.0, \"negative\": 11063.0, \"pending\": 860.0, \"hospitalized\": 217.0, \"death\": 14.0, \"total\": 13094, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.08943027340766764, \"total/100k\": 60.96545460073377, \"positive/100k\": 5.45215727336637}, {\"state\": \"CA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 1733.0, \"negative\": 12567.0, \"pending\": 12100.0, \"hospitalized\": null, \"death\": 27.0, \"total\": 26400, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.0656439393939394, \"total/100k\": 66.81476767328428, \"positive/100k\": 4.385984559765215}, {\"state\": \"IA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 105.0, \"negative\": 2043.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 2148, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.04888268156424581, \"total/100k\": 68.08089836358623, \"positive/100k\": 3.327976875314969}, {\"state\": \"ID\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 47.0, \"negative\": 1309.0, \"pending\": null, \"hospitalized\": null, \"death\": 0.0, \"total\": 1356, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.03466076696165192, \"total/100k\": 75.66689824308828, \"positive/100k\": 2.6226727267147116}, {\"state\": \"IL\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 1285.0, \"negative\": 8583.0, \"pending\": null, \"hospitalized\": null, \"death\": 12.0, \"total\": 9868, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.13021888933927847, \"total/100k\": 77.87357476088086, \"positive/100k\": 10.140610414241173}, {\"state\": \"NC\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 297.0, \"negative\": 8141.0, \"pending\": null, \"hospitalized\": null, \"death\": 0.0, \"total\": 8438, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.03519791419767718, \"total/100k\": 80.45320765928267, \"positive/100k\": 2.8317851001193355}, {\"state\": \"MN\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 235.0, \"negative\": 4511.0, \"pending\": null, \"hospitalized\": 17.0, \"death\": 1.0, \"total\": 4746, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.049515381373788456, \"total/100k\": 84.15442709737088, \"positive/100k\": 4.166938552018997}, {\"state\": \"OR\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 191.0, \"negative\": 3649.0, \"pending\": null, \"hospitalized\": 56.0, \"death\": 5.0, \"total\": 3840, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.04973958333333333, \"total/100k\": 91.04408359269438, \"positive/100k\": 4.528494782865788}, {\"state\": \"CO\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 591.0, \"negative\": 4845.0, \"pending\": null, \"hospitalized\": 58.0, \"death\": 6.0, \"total\": 5436, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.108719646799117, \"total/100k\": 94.39571461515166, \"positive/100k\": 10.262668752309533}, {\"state\": \"WY\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 26.0, \"negative\": 592.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 618, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.042071197411003236, \"total/100k\": 106.78019693862213, \"positive/100k\": 4.492370744990575}, {\"state\": \"MT\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 34.0, \"negative\": 1146.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 1180, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.0288135593220339, \"total/100k\": 110.4064642049144, \"positive/100k\": 3.181203205904313}, {\"state\": \"RI\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 106.0, \"negative\": 932.0, \"pending\": 216.0, \"hospitalized\": null, \"death\": null, \"total\": 1254, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.08452950558213716, \"total/100k\": 118.37324575852803, \"positive/100k\": 10.006031938121188}, {\"state\": \"SD\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 28.0, \"negative\": 762.0, \"pending\": 265.0, \"hospitalized\": null, \"death\": 1.0, \"total\": 1055, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.026540284360189573, \"total/100k\": 119.2549897757215, \"positive/100k\": 3.1650613400191485}, {\"state\": \"NV\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 245.0, \"negative\": 3490.0, \"pending\": 0.0, \"hospitalized\": null, \"death\": 4.0, \"total\": 3735, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.06559571619812583, \"total/100k\": 121.26009202131321, \"positive/100k\": 7.954142582388684}, {\"state\": \"CT\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 415.0, \"negative\": 4085.0, \"pending\": null, \"hospitalized\": 54.0, \"death\": 10.0, \"total\": 4500, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.09222222222222222, \"total/100k\": 126.21704788422362, \"positive/100k\": 11.640016638211735}, {\"state\": \"LA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 1172.0, \"negative\": 4776.0, \"pending\": null, \"hospitalized\": null, \"death\": 34.0, \"total\": 5948, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.19704102219233355, \"total/100k\": 127.94716221024206, \"positive/100k\": 25.210839628514403}, {\"state\": \"WI\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 416.0, \"negative\": 7050.0, \"pending\": null, \"hospitalized\": null, \"death\": 5.0, \"total\": 7466, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.055719260648272165, \"total/100k\": 128.22816025050693, \"positive/100k\": 7.144778283446407}, {\"state\": \"MA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 777.0, \"negative\": 8145.0, \"pending\": null, \"hospitalized\": 79.0, \"death\": 9.0, \"total\": 8922, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.08708809683927371, \"total/100k\": 128.38328150948348, \"positive/100k\": 11.180655652641635}, {\"state\": \"AK\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 22.0, \"negative\": 946.0, \"pending\": null, \"hospitalized\": 0.0, \"death\": null, \"total\": 968, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.022727272727272728, \"total/100k\": 132.32268691604753, \"positive/100k\": 3.007333793546535}, {\"state\": \"UT\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 257.0, \"negative\": 4790.0, \"pending\": null, \"hospitalized\": null, \"death\": 1.0, \"total\": 5047, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.05092133940955023, \"total/100k\": 157.42564313069605, \"positive/100k\": 8.016324605624902}, {\"state\": \"NH\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 78.0, \"negative\": 1374.0, \"pending\": 889.0, \"hospitalized\": null, \"death\": null, \"total\": 2341, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.03331909440410081, \"total/100k\": 172.1689388406801, \"positive/100k\": 5.73651312668648}, {\"state\": \"DC\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 116.0, \"negative\": 1113.0, \"pending\": null, \"hospitalized\": null, \"death\": 2.0, \"total\": 1229, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.09438567941415785, \"total/100k\": 174.14123151432025, \"positive/100k\": 16.436438450497274}, {\"state\": \"ND\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 30.0, \"negative\": 1353.0, \"pending\": null, \"hospitalized\": 4.0, \"death\": 0.0, \"total\": 1383, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.021691973969631236, \"total/100k\": 181.48129679737343, \"positive/100k\": 3.936687566103545}, {\"state\": \"VT\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 75.0, \"negative\": 1106.0, \"pending\": null, \"hospitalized\": null, \"death\": 5.0, \"total\": 1181, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.06350550381033022, \"total/100k\": 189.26615693545878, \"positive/100k\": 12.019442650431337}, {\"state\": \"HI\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 56.0, \"negative\": 2955.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 3011, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.018598472268349386, \"total/100k\": 212.6604664828459, \"positive/100k\": 3.9551597884554535}, {\"state\": \"ME\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 107.0, \"negative\": 2791.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 2898, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.03692201518288475, \"total/100k\": 215.5909930873999, \"positive/100k\": 7.960053920066181}, {\"state\": \"NM\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 65.0, \"negative\": 5321.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 5386, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.012068325287783142, \"total/100k\": 256.8640551995418, \"positive/100k\": 3.099918972887155}, {\"state\": \"NY\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 20875.0, \"negative\": 57414.0, \"pending\": null, \"hospitalized\": 2635.0, \"death\": 114.0, \"total\": 78289, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.2666402687478445, \"total/100k\": 402.44045807346015, \"positive/100k\": 107.30683189571309}, {\"state\": \"WA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 1996.0, \"negative\": 28879.0, \"pending\": null, \"hospitalized\": null, \"death\": 95.0, \"total\": 30875, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.06464777327935223, \"total/100k\": 405.4554673322396, \"positive/100k\": 26.211793126968427}, {\"state\": \"AS\", \"date\": \"2020-03-23T00:00:00\", \"positive\": null, \"negative\": null, \"pending\": null, \"hospitalized\": null, \"death\": 0.0, \"total\": 0, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": null, \"total/100k\": null, \"positive/100k\": null}, {\"state\": \"GU\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 29.0, \"negative\": 161.0, \"pending\": null, \"hospitalized\": null, \"death\": 1.0, \"total\": 190, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.15263157894736842, \"total/100k\": null, \"positive/100k\": null}, {\"state\": \"MP\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 0.0, \"negative\": null, \"pending\": null, \"hospitalized\": null, \"death\": 0.0, \"total\": 0, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": null, \"total/100k\": null, \"positive/100k\": null}, {\"state\": \"PR\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 31.0, \"negative\": 189.0, \"pending\": 35.0, \"hospitalized\": null, \"death\": 2.0, \"total\": 255, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.12156862745098039, \"total/100k\": null, \"positive/100k\": null}, {\"state\": \"VI\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 17.0, \"negative\": null, \"pending\": null, \"hospitalized\": null, \"death\": 0.0, \"total\": 17, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 1.0, \"total/100k\": null, \"positive/100k\": null}]}}, {\"mode\": \"vega-lite\"});\n",
       "</script>"
      ],
      "text/plain": [
       "alt.LayerChart(...)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<p style=\"font-size: smaller\">Data Sources: \n",
       "  <a href=\"https://covidtracking.com\">The COVID Tracking Project</a>\n",
       "<br>\n",
       "Analysis and Visualization:\n",
       "  <a href=\"https://renkulab.io/projects/covid-19/covid-19-public-data\">Covid-19 Public Data Collaboration Project</a>\n",
       "</p>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "chart = alt.Chart(most_recent_df.sort_values('total/100k'), title=\"Cases per 100k\").encode(alt.X('state', sort=None))\n",
    "tests = chart.mark_bar().encode(alt.Y('total/100k'))\n",
    "positives = chart.mark_point(color='orange', filled=True, size=100, opacity=1).encode(alt.Y('positive/100k'))\n",
    "display(alt.layer(tests, positives))\n",
    "display(html_credits)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Counts and rates by state\n",
    "\n",
    "Taking a look at the three states with the highest per-capita incidence of covid-19. The red and yellow curves represent the total tests and total positive tests respectively. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<div id=\"altair-viz-f9160d38ef744717870e719ef7bd8c70\"></div>\n",
       "<script type=\"text/javascript\">\n",
       "  (function(spec, embedOpt){\n",
       "    const outputDiv = document.getElementById(\"altair-viz-f9160d38ef744717870e719ef7bd8c70\");\n",
       "    const paths = {\n",
       "      \"vega\": \"https://cdn.jsdelivr.net/npm//vega@5?noext\",\n",
       "      \"vega-lib\": \"https://cdn.jsdelivr.net/npm//vega-lib?noext\",\n",
       "      \"vega-lite\": \"https://cdn.jsdelivr.net/npm//vega-lite@4.0.2?noext\",\n",
       "      \"vega-embed\": \"https://cdn.jsdelivr.net/npm//vega-embed@6?noext\",\n",
       "    };\n",
       "\n",
       "    function loadScript(lib) {\n",
       "      return new Promise(function(resolve, reject) {\n",
       "        var s = document.createElement('script');\n",
       "        s.src = paths[lib];\n",
       "        s.async = true;\n",
       "        s.onload = () => resolve(paths[lib]);\n",
       "        s.onerror = () => reject(`Error loading script: ${paths[lib]}`);\n",
       "        document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "      });\n",
       "    }\n",
       "\n",
       "    function showError(err) {\n",
       "      outputDiv.innerHTML = `<div class=\"error\" style=\"color:red;\">${err}</div>`;\n",
       "      throw err;\n",
       "    }\n",
       "\n",
       "    function displayChart(vegaEmbed) {\n",
       "      vegaEmbed(outputDiv, spec, embedOpt)\n",
       "        .catch(err => showError(`Javascript Error: ${err.message}<br>This usually means there's a typo in your chart specification. See the javascript console for the full traceback.`));\n",
       "    }\n",
       "\n",
       "    if(typeof define === \"function\" && define.amd) {\n",
       "      requirejs.config({paths});\n",
       "      require([\"vega-embed\"], displayChart, err => showError(`Error loading script: ${err.message}`));\n",
       "    } else if (typeof vegaEmbed === \"function\") {\n",
       "      displayChart(vegaEmbed);\n",
       "    } else {\n",
       "      loadScript(\"vega\")\n",
       "        .then(() => loadScript(\"vega-lite\"))\n",
       "        .then(() => loadScript(\"vega-embed\"))\n",
       "        .catch(showError)\n",
       "        .then(() => displayChart(vegaEmbed));\n",
       "    }\n",
       "  })({\"config\": {\"view\": {\"continuousWidth\": 400, \"continuousHeight\": 300}}, \"hconcat\": [{\"layer\": [{\"mark\": {\"type\": \"bar\", \"size\": 10}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Daily positive\"}, \"field\": \"positive_diff\"}}, \"height\": 150, \"title\": \"NY\", \"width\": 250}, {\"layer\": [{\"mark\": {\"type\": \"line\", \"color\": \"red\"}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Total/10\"}, \"field\": \"total_10\"}}, \"height\": 150, \"title\": \"NY\", \"width\": 250}, {\"mark\": {\"type\": \"line\", \"color\": \"orange\"}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Positive\"}, \"field\": \"positive\"}}, \"height\": 150, \"title\": \"NY\", \"width\": 250}]}], \"data\": {\"name\": \"data-590167a331dd42966295eeba4d7d31c5\"}, \"resolve\": {\"scale\": {\"y\": \"independent\"}}}, {\"layer\": [{\"mark\": {\"type\": \"bar\", \"size\": 10}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Daily positive\"}, \"field\": \"positive_diff\"}}, \"height\": 150, \"title\": \"WA\", \"width\": 250}, {\"layer\": [{\"mark\": {\"type\": \"line\", \"color\": \"red\"}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Total/10\"}, \"field\": \"total_10\"}}, \"height\": 150, \"title\": \"WA\", \"width\": 250}, {\"mark\": {\"type\": \"line\", \"color\": \"orange\"}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Positive\"}, \"field\": \"positive\"}}, \"height\": 150, \"title\": \"WA\", \"width\": 250}]}], \"data\": {\"name\": \"data-53d3a60ae6c0fa50968d9fe5fc3ab938\"}, \"resolve\": {\"scale\": {\"y\": \"independent\"}}}, {\"layer\": [{\"mark\": {\"type\": \"bar\", \"size\": 10}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Daily positive\"}, \"field\": \"positive_diff\"}}, \"height\": 150, \"title\": \"NM\", \"width\": 250}, {\"layer\": [{\"mark\": {\"type\": \"line\", \"color\": \"red\"}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Total/10\"}, \"field\": \"total_10\"}}, \"height\": 150, \"title\": \"NM\", \"width\": 250}, {\"mark\": {\"type\": \"line\", \"color\": \"orange\"}, \"encoding\": {\"x\": {\"type\": \"temporal\", \"axis\": {\"title\": \"Date\"}, \"field\": \"date\"}, \"y\": {\"type\": \"quantitative\", \"axis\": {\"title\": \"Positive\"}, \"field\": \"positive\"}}, \"height\": 150, \"title\": \"NM\", \"width\": 250}]}], \"data\": {\"name\": \"data-2f1ed1b3ec653d924910cb18c09a4230\"}, \"resolve\": {\"scale\": {\"y\": \"independent\"}}}], \"$schema\": \"https://vega.github.io/schema/vega-lite/v4.0.2.json\", \"datasets\": {\"data-590167a331dd42966295eeba4d7d31c5\": [{\"state\": \"NY\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 20875.0, \"negative\": 57414.0, \"pending\": null, \"hospitalized\": 2635.0, \"death\": 114.0, \"total\": 78289, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.2666402687478445, \"positive_diff\": 5707.0, \"negative_diff\": 11181.0, \"death_diff\": 0.0, \"positive_diff_100k\": 29.336531239704644, \"death_diff_100k\": 0.0, \"total_10\": 7828.9}, {\"state\": \"NY\", \"date\": \"2020-03-22T00:00:00\", \"positive\": 15168.0, \"negative\": 46233.0, \"pending\": null, \"hospitalized\": 1974.0, \"death\": 114.0, \"total\": 61401, \"dateChecked\": \"2020-03-22T20:00:00Z\", \"ratio\": 0.24703180729955537, \"positive_diff\": 4812.0, \"negative_diff\": 11152.0, \"death_diff\": 70.0, \"positive_diff_100k\": 24.735831141660903, \"death_diff_100k\": 0.3598312925844271, \"total_10\": 6140.1}, {\"state\": \"NY\", \"date\": \"2020-03-21T00:00:00\", \"positive\": 10356.0, \"negative\": 35081.0, \"pending\": null, \"hospitalized\": 1603.0, \"death\": 44.0, \"total\": 45437, \"dateChecked\": \"2020-03-21T20:00:00Z\", \"ratio\": 0.2279199771111649, \"positive_diff\": 3254.0, \"negative_diff\": 9756.0, \"death_diff\": 9.0, \"positive_diff_100k\": 16.72701465813894, \"death_diff_100k\": 0.04626402333228348, \"total_10\": 4543.7}, {\"state\": \"NY\", \"date\": \"2020-03-20T00:00:00\", \"positive\": 7102.0, \"negative\": 25325.0, \"pending\": null, \"hospitalized\": null, \"death\": 35.0, \"total\": 32427, \"dateChecked\": \"2020-03-20T20:00:00Z\", \"ratio\": 0.21901501834890677, \"positive_diff\": 2950.0, \"negative_diff\": 7193.0, \"death_diff\": 23.0, \"positive_diff_100k\": 15.16431875891514, \"death_diff_100k\": 0.11823028184916891, \"total_10\": 3242.7}, {\"state\": \"NY\", \"date\": \"2020-03-19T00:00:00\", \"positive\": 4152.0, \"negative\": 18132.0, \"pending\": null, \"hospitalized\": null, \"death\": 12.0, \"total\": 22284, \"dateChecked\": \"2020-03-19T20:00:00Z\", \"ratio\": 0.18632202477113624, \"positive_diff\": 1770.0, \"negative_diff\": 5917.0, \"death_diff\": 0.0, \"positive_diff_100k\": 9.098591255349085, \"death_diff_100k\": 0.0, \"total_10\": 2228.4}, {\"state\": \"NY\", \"date\": \"2020-03-18T00:00:00\", \"positive\": 2382.0, \"negative\": 12215.0, \"pending\": null, \"hospitalized\": null, \"death\": 12.0, \"total\": 14597, \"dateChecked\": \"2020-03-18T20:00:00Z\", \"ratio\": 0.1631842159347811, \"positive_diff\": 682.0, \"negative_diff\": 6709.0, \"death_diff\": 5.0, \"positive_diff_100k\": 3.505784879179704, \"death_diff_100k\": 0.02570223518460193, \"total_10\": 1459.7}, {\"state\": \"NY\", \"date\": \"2020-03-17T00:00:00\", \"positive\": 1700.0, \"negative\": 5506.0, \"pending\": null, \"hospitalized\": null, \"death\": 7.0, \"total\": 7206, \"dateChecked\": \"2020-03-17T20:00:00Z\", \"ratio\": 0.23591451568137664, \"positive_diff\": 750.0, \"negative_diff\": 963.0, \"death_diff\": 0.0, \"positive_diff_100k\": 3.85533527769029, \"death_diff_100k\": 0.0, \"total_10\": 720.6}, {\"state\": \"NY\", \"date\": \"2020-03-16T00:00:00\", \"positive\": 950.0, \"negative\": 4543.0, \"pending\": null, \"hospitalized\": null, \"death\": 7.0, \"total\": 5493, \"dateChecked\": \"2020-03-16T20:00:00Z\", \"ratio\": 0.17294738758419806, \"positive_diff\": 221.0, \"negative_diff\": 0.0, \"death_diff\": 4.0, \"positive_diff_100k\": 1.1360387951594055, \"death_diff_100k\": 0.020561788147681545, \"total_10\": 549.3}, {\"state\": \"NY\", \"date\": \"2020-03-15T00:00:00\", \"positive\": 729.0, \"negative\": 4543.0, \"pending\": null, \"hospitalized\": null, \"death\": 3.0, \"total\": 5272, \"dateChecked\": \"2020-03-15T20:00:00Z\", \"ratio\": 0.13827769347496208, \"positive_diff\": 205.0, \"negative_diff\": 1764.0, \"death_diff\": null, \"positive_diff_100k\": 1.0537916425686793, \"death_diff_100k\": null, \"total_10\": 527.2}, {\"state\": \"NY\", \"date\": \"2020-03-14T00:00:00\", \"positive\": 524.0, \"negative\": 2779.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 3303, \"dateChecked\": \"2020-03-14T20:00:00Z\", \"ratio\": 0.15864365728125945, \"positive_diff\": 103.0, \"negative_diff\": 0.0, \"death_diff\": null, \"positive_diff_100k\": 0.5294660448027999, \"death_diff_100k\": null, \"total_10\": 330.3}, {\"state\": \"NY\", \"date\": \"2020-03-13T00:00:00\", \"positive\": 421.0, \"negative\": 2779.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 3200, \"dateChecked\": \"2020-03-13T20:00:00Z\", \"ratio\": 0.1315625, \"positive_diff\": 205.0, \"negative_diff\": null, \"death_diff\": null, \"positive_diff_100k\": 1.0537916425686793, \"death_diff_100k\": null, \"total_10\": 320.0}, {\"state\": \"NY\", \"date\": \"2020-03-12T00:00:00\", \"positive\": 216.0, \"negative\": null, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 216, \"dateChecked\": \"2020-03-12T20:00:00Z\", \"ratio\": 1.0, \"positive_diff\": 0.0, \"negative_diff\": null, \"death_diff\": null, \"positive_diff_100k\": 0.0, \"death_diff_100k\": null, \"total_10\": 21.6}, {\"state\": \"NY\", \"date\": \"2020-03-11T00:00:00\", \"positive\": 216.0, \"negative\": null, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 216, \"dateChecked\": \"2020-03-11T20:00:00Z\", \"ratio\": 1.0, \"positive_diff\": 43.0, \"negative_diff\": null, \"death_diff\": null, \"positive_diff_100k\": 0.22103922258757666, \"death_diff_100k\": null, \"total_10\": 21.6}, {\"state\": \"NY\", \"date\": \"2020-03-10T00:00:00\", \"positive\": 173.0, \"negative\": 92.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 265, \"dateChecked\": \"2020-03-10T20:00:00Z\", \"ratio\": 0.6528301886792452, \"positive_diff\": 31.0, \"negative_diff\": 0.0, \"death_diff\": null, \"positive_diff_100k\": 0.15935385814453198, \"death_diff_100k\": null, \"total_10\": 26.5}, {\"state\": \"NY\", \"date\": \"2020-03-09T00:00:00\", \"positive\": 142.0, \"negative\": 92.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 234, \"dateChecked\": \"2020-03-09T20:00:00Z\", \"ratio\": 0.6068376068376068, \"positive_diff\": 37.0, \"negative_diff\": 0.0, \"death_diff\": null, \"positive_diff_100k\": 0.19019654036605432, \"death_diff_100k\": null, \"total_10\": 23.4}, {\"state\": \"NY\", \"date\": \"2020-03-08T00:00:00\", \"positive\": 105.0, \"negative\": 92.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 197, \"dateChecked\": \"2020-03-08T20:00:00Z\", \"ratio\": 0.5329949238578681, \"positive_diff\": 29.0, \"negative_diff\": 0.0, \"death_diff\": null, \"positive_diff_100k\": 0.14907296407069123, \"death_diff_100k\": null, \"total_10\": 19.7}, {\"state\": \"NY\", \"date\": \"2020-03-07T00:00:00\", \"positive\": 76.0, \"negative\": 92.0, \"pending\": 236.0, \"hospitalized\": null, \"death\": null, \"total\": 404, \"dateChecked\": \"2020-03-07T21:00:00Z\", \"ratio\": 0.18811881188118812, \"positive_diff\": 43.0, \"negative_diff\": 0.0, \"death_diff\": null, \"positive_diff_100k\": 0.22103922258757666, \"death_diff_100k\": null, \"total_10\": 40.4}, {\"state\": \"NY\", \"date\": \"2020-03-06T00:00:00\", \"positive\": 33.0, \"negative\": 92.0, \"pending\": 236.0, \"hospitalized\": null, \"death\": null, \"total\": 361, \"dateChecked\": \"2020-03-06T21:00:00Z\", \"ratio\": 0.09141274238227147, \"positive_diff\": 11.0, \"negative_diff\": 16.0, \"death_diff\": null, \"positive_diff_100k\": 0.05654491740612426, \"death_diff_100k\": null, \"total_10\": 36.1}, {\"state\": \"NY\", \"date\": \"2020-03-05T00:00:00\", \"positive\": 22.0, \"negative\": 76.0, \"pending\": 24.0, \"hospitalized\": null, \"death\": null, \"total\": 122, \"dateChecked\": \"2020-03-05T21:00:00Z\", \"ratio\": 0.18032786885245902, \"positive_diff\": 16.0, \"negative_diff\": 28.0, \"death_diff\": null, \"positive_diff_100k\": 0.08224715259072618, \"death_diff_100k\": null, \"total_10\": 12.2}, {\"state\": \"NY\", \"date\": \"2020-03-04T00:00:00\", \"positive\": 6.0, \"negative\": 48.0, \"pending\": 24.0, \"hospitalized\": null, \"death\": null, \"total\": 78, \"dateChecked\": \"2020-03-04T21:00:00Z\", \"ratio\": 0.07692307692307693, \"positive_diff\": null, \"negative_diff\": null, \"death_diff\": null, \"positive_diff_100k\": null, \"death_diff_100k\": null, \"total_10\": 7.8}], \"data-53d3a60ae6c0fa50968d9fe5fc3ab938\": [{\"state\": \"WA\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 1996.0, \"negative\": 28879.0, \"pending\": null, \"hospitalized\": null, \"death\": 95.0, \"total\": 30875, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.06464777327935223, \"positive_diff\": 203.0, \"negative_diff\": 3551.0, \"death_diff\": 1.0, \"positive_diff_100k\": 2.665828659706709, \"death_diff_100k\": 0.013132160885254724, \"total_10\": 3087.5}, {\"state\": \"WA\", \"date\": \"2020-03-22T00:00:00\", \"positive\": 1793.0, \"negative\": 25328.0, \"pending\": null, \"hospitalized\": null, \"death\": 94.0, \"total\": 27121, \"dateChecked\": \"2020-03-22T20:00:00Z\", \"ratio\": 0.06611113159544264, \"positive_diff\": 269.0, \"negative_diff\": 3609.0, \"death_diff\": 11.0, \"positive_diff_100k\": 3.532551278133521, \"death_diff_100k\": 0.14445376973780194, \"total_10\": 2712.1}, {\"state\": \"WA\", \"date\": \"2020-03-21T00:00:00\", \"positive\": 1524.0, \"negative\": 21719.0, \"pending\": null, \"hospitalized\": null, \"death\": 83.0, \"total\": 23243, \"dateChecked\": \"2020-03-21T20:00:00Z\", \"ratio\": 0.06556812803854924, \"positive_diff\": 148.0, \"negative_diff\": 2383.0, \"death_diff\": 9.0, \"positive_diff_100k\": 1.9435598110176993, \"death_diff_100k\": 0.11818944796729251, \"total_10\": 2324.3}, {\"state\": \"WA\", \"date\": \"2020-03-20T00:00:00\", \"positive\": 1376.0, \"negative\": 19336.0, \"pending\": null, \"hospitalized\": null, \"death\": 74.0, \"total\": 20712, \"dateChecked\": \"2020-03-20T20:00:00Z\", \"ratio\": 0.0664349169563538, \"positive_diff\": 189.0, \"negative_diff\": 3418.0, \"death_diff\": 8.0, \"positive_diff_100k\": 2.4819784073131426, \"death_diff_100k\": 0.10505728708203779, \"total_10\": 2071.2}, {\"state\": \"WA\", \"date\": \"2020-03-19T00:00:00\", \"positive\": 1187.0, \"negative\": 15918.0, \"pending\": null, \"hospitalized\": null, \"death\": 66.0, \"total\": 17105, \"dateChecked\": \"2020-03-19T20:00:00Z\", \"ratio\": 0.06939491376790412, \"positive_diff\": 175.0, \"negative_diff\": 2801.0, \"death_diff\": 14.0, \"positive_diff_100k\": 2.298128154919577, \"death_diff_100k\": 0.18385025239356614, \"total_10\": 1710.5}, {\"state\": \"WA\", \"date\": \"2020-03-18T00:00:00\", \"positive\": 1012.0, \"negative\": 13117.0, \"pending\": null, \"hospitalized\": null, \"death\": 52.0, \"total\": 14129, \"dateChecked\": \"2020-03-18T20:00:00Z\", \"ratio\": 0.07162573430532947, \"positive_diff\": 108.0, \"negative_diff\": 1535.0, \"death_diff\": 4.0, \"positive_diff_100k\": 1.41827337560751, \"death_diff_100k\": 0.052528643541018896, \"total_10\": 1412.9}, {\"state\": \"WA\", \"date\": \"2020-03-17T00:00:00\", \"positive\": 904.0, \"negative\": 11582.0, \"pending\": null, \"hospitalized\": null, \"death\": 48.0, \"total\": 12486, \"dateChecked\": \"2020-03-17T20:00:00Z\", \"ratio\": 0.07240108921992632, \"positive_diff\": 135.0, \"negative_diff\": 2131.0, \"death_diff\": 6.0, \"positive_diff_100k\": 1.7728417195093877, \"death_diff_100k\": 0.07879296531152834, \"total_10\": 1248.6}, {\"state\": \"WA\", \"date\": \"2020-03-16T00:00:00\", \"positive\": 769.0, \"negative\": 9451.0, \"pending\": null, \"hospitalized\": null, \"death\": 42.0, \"total\": 10220, \"dateChecked\": \"2020-03-16T20:00:00Z\", \"ratio\": 0.07524461839530333, \"positive_diff\": 127.0, \"negative_diff\": 2329.0, \"death_diff\": 2.0, \"positive_diff_100k\": 1.6677844324273499, \"death_diff_100k\": 0.026264321770509448, \"total_10\": 1022.0}, {\"state\": \"WA\", \"date\": \"2020-03-15T00:00:00\", \"positive\": 642.0, \"negative\": 7122.0, \"pending\": null, \"hospitalized\": null, \"death\": 40.0, \"total\": 7764, \"dateChecked\": \"2020-03-15T20:00:00Z\", \"ratio\": 0.08268933539412673, \"positive_diff\": 74.0, \"negative_diff\": 1121.0, \"death_diff\": 3.0, \"positive_diff_100k\": 0.9717799055088496, \"death_diff_100k\": 0.03939648265576417, \"total_10\": 776.4}, {\"state\": \"WA\", \"date\": \"2020-03-14T00:00:00\", \"positive\": 568.0, \"negative\": 6001.0, \"pending\": null, \"hospitalized\": null, \"death\": 37.0, \"total\": 6569, \"dateChecked\": \"2020-03-14T20:00:00Z\", \"ratio\": 0.08646673770741362, \"positive_diff\": 111.0, \"negative_diff\": 1651.0, \"death_diff\": 6.0, \"positive_diff_100k\": 1.4576698582632743, \"death_diff_100k\": 0.07879296531152834, \"total_10\": 656.9}, {\"state\": \"WA\", \"date\": \"2020-03-13T00:00:00\", \"positive\": 457.0, \"negative\": 4350.0, \"pending\": null, \"hospitalized\": null, \"death\": 31.0, \"total\": 4807, \"dateChecked\": \"2020-03-13T20:00:00Z\", \"ratio\": 0.0950696900353651, \"positive_diff\": 120.0, \"negative_diff\": 1313.0, \"death_diff\": 2.0, \"positive_diff_100k\": 1.575859306230567, \"death_diff_100k\": 0.026264321770509448, \"total_10\": 480.7}, {\"state\": \"WA\", \"date\": \"2020-03-12T00:00:00\", \"positive\": 337.0, \"negative\": 3037.0, \"pending\": null, \"hospitalized\": null, \"death\": 29.0, \"total\": 3403, \"dateChecked\": \"2020-03-12T20:00:00Z\", \"ratio\": 0.09903026741110785, \"positive_diff\": 70.0, \"negative_diff\": 862.0, \"death_diff\": 5.0, \"positive_diff_100k\": 0.9192512619678306, \"death_diff_100k\": 0.06566080442627362, \"total_10\": 340.3}, {\"state\": \"WA\", \"date\": \"2020-03-11T00:00:00\", \"positive\": 267.0, \"negative\": 2175.0, \"pending\": null, \"hospitalized\": null, \"death\": 24.0, \"total\": 2466, \"dateChecked\": \"2020-03-11T20:00:00Z\", \"ratio\": 0.10827250608272507, \"positive_diff\": 105.0, \"negative_diff\": 1065.0, \"death_diff\": null, \"positive_diff_100k\": 1.3788768929517459, \"death_diff_100k\": null, \"total_10\": 246.6}, {\"state\": \"WA\", \"date\": \"2020-03-10T00:00:00\", \"positive\": 162.0, \"negative\": 1110.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 1272, \"dateChecked\": \"2020-03-10T20:00:00Z\", \"ratio\": 0.12735849056603774, \"positive_diff\": 26.0, \"negative_diff\": 0.0, \"death_diff\": null, \"positive_diff_100k\": 0.3414361830166228, \"death_diff_100k\": null, \"total_10\": 127.2}, {\"state\": \"WA\", \"date\": \"2020-03-09T00:00:00\", \"positive\": 136.0, \"negative\": 1110.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 1246, \"dateChecked\": \"2020-03-09T20:00:00Z\", \"ratio\": 0.10914927768860354, \"positive_diff\": 34.0, \"negative_diff\": 470.0, \"death_diff\": null, \"positive_diff_100k\": 0.44649347009866064, \"death_diff_100k\": null, \"total_10\": 124.6}, {\"state\": \"WA\", \"date\": \"2020-03-08T00:00:00\", \"positive\": 102.0, \"negative\": 640.0, \"pending\": 60.0, \"hospitalized\": null, \"death\": null, \"total\": 802, \"dateChecked\": \"2020-03-08T20:00:00Z\", \"ratio\": 0.12718204488778054, \"positive_diff\": 0.0, \"negative_diff\": 270.0, \"death_diff\": null, \"positive_diff_100k\": 0.0, \"death_diff_100k\": null, \"total_10\": 80.2}, {\"state\": \"WA\", \"date\": \"2020-03-07T00:00:00\", \"positive\": 102.0, \"negative\": 370.0, \"pending\": 66.0, \"hospitalized\": null, \"death\": null, \"total\": 538, \"dateChecked\": \"2020-03-07T21:00:00Z\", \"ratio\": 0.1895910780669145, \"positive_diff\": 23.0, \"negative_diff\": 0.0, \"death_diff\": null, \"positive_diff_100k\": 0.30203970036085864, \"death_diff_100k\": null, \"total_10\": 53.8}, {\"state\": \"WA\", \"date\": \"2020-03-06T00:00:00\", \"positive\": 79.0, \"negative\": 370.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 449, \"dateChecked\": \"2020-03-06T21:00:00Z\", \"ratio\": 0.1759465478841871, \"positive_diff\": 9.0, \"negative_diff\": null, \"death_diff\": null, \"positive_diff_100k\": 0.11818944796729251, \"death_diff_100k\": null, \"total_10\": 44.9}, {\"state\": \"WA\", \"date\": \"2020-03-05T00:00:00\", \"positive\": 70.0, \"negative\": null, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 70, \"dateChecked\": \"2020-03-05T21:00:00Z\", \"ratio\": 1.0, \"positive_diff\": 31.0, \"negative_diff\": null, \"death_diff\": null, \"positive_diff_100k\": 0.4070969874428964, \"death_diff_100k\": null, \"total_10\": 7.0}, {\"state\": \"WA\", \"date\": \"2020-03-04T00:00:00\", \"positive\": 39.0, \"negative\": null, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 39, \"dateChecked\": \"2020-03-04T21:00:00Z\", \"ratio\": 1.0, \"positive_diff\": null, \"negative_diff\": null, \"death_diff\": null, \"positive_diff_100k\": null, \"death_diff_100k\": null, \"total_10\": 3.9}], \"data-2f1ed1b3ec653d924910cb18c09a4230\": [{\"state\": \"NM\", \"date\": \"2020-03-23T00:00:00\", \"positive\": 65.0, \"negative\": 5321.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 5386, \"dateChecked\": \"2020-03-23T20:00:00Z\", \"ratio\": 0.012068325287783142, \"positive_diff\": 8.0, \"negative_diff\": 599.0, \"death_diff\": null, \"positive_diff_100k\": 0.3815284889707268, \"death_diff_100k\": null, \"total_10\": 538.6}, {\"state\": \"NM\", \"date\": \"2020-03-22T00:00:00\", \"positive\": 57.0, \"negative\": 4722.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 4779, \"dateChecked\": \"2020-03-22T20:00:00Z\", \"ratio\": 0.011927181418706842, \"positive_diff\": 0.0, \"negative_diff\": 951.0, \"death_diff\": null, \"positive_diff_100k\": 0.0, \"death_diff_100k\": null, \"total_10\": 477.9}, {\"state\": \"NM\", \"date\": \"2020-03-21T00:00:00\", \"positive\": 57.0, \"negative\": 3771.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 3828, \"dateChecked\": \"2020-03-21T20:00:00Z\", \"ratio\": 0.014890282131661442, \"positive_diff\": 14.0, \"negative_diff\": 0.0, \"death_diff\": null, \"positive_diff_100k\": 0.6676748556987718, \"death_diff_100k\": null, \"total_10\": 382.8}, {\"state\": \"NM\", \"date\": \"2020-03-20T00:00:00\", \"positive\": 43.0, \"negative\": 3771.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 3814, \"dateChecked\": \"2020-03-20T20:00:00Z\", \"ratio\": 0.011274252753015208, \"positive_diff\": 8.0, \"negative_diff\": 1009.0, \"death_diff\": null, \"positive_diff_100k\": 0.3815284889707268, \"death_diff_100k\": null, \"total_10\": 381.4}, {\"state\": \"NM\", \"date\": \"2020-03-19T00:00:00\", \"positive\": 35.0, \"negative\": 2762.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 2797, \"dateChecked\": \"2020-03-19T20:00:00Z\", \"ratio\": 0.012513407222023596, \"positive_diff\": 7.0, \"negative_diff\": 436.0, \"death_diff\": null, \"positive_diff_100k\": 0.3338374278493859, \"death_diff_100k\": null, \"total_10\": 279.7}, {\"state\": \"NM\", \"date\": \"2020-03-18T00:00:00\", \"positive\": 28.0, \"negative\": 2326.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 2354, \"dateChecked\": \"2020-03-18T20:00:00Z\", \"ratio\": 0.0118946474086661, \"positive_diff\": 5.0, \"negative_diff\": 1077.0, \"death_diff\": null, \"positive_diff_100k\": 0.23845530560670422, \"death_diff_100k\": null, \"total_10\": 235.4}, {\"state\": \"NM\", \"date\": \"2020-03-17T00:00:00\", \"positive\": 23.0, \"negative\": 1249.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 1272, \"dateChecked\": \"2020-03-17T20:00:00Z\", \"ratio\": 0.018081761006289308, \"positive_diff\": 6.0, \"negative_diff\": 683.0, \"death_diff\": null, \"positive_diff_100k\": 0.28614636672804505, \"death_diff_100k\": null, \"total_10\": 127.2}, {\"state\": \"NM\", \"date\": \"2020-03-16T00:00:00\", \"positive\": 17.0, \"negative\": 566.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 583, \"dateChecked\": \"2020-03-16T20:00:00Z\", \"ratio\": 0.029159519725557463, \"positive_diff\": 4.0, \"negative_diff\": 84.0, \"death_diff\": null, \"positive_diff_100k\": 0.1907642444853634, \"death_diff_100k\": null, \"total_10\": 58.3}, {\"state\": \"NM\", \"date\": \"2020-03-15T00:00:00\", \"positive\": 13.0, \"negative\": 482.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 495, \"dateChecked\": \"2020-03-15T20:00:00Z\", \"ratio\": 0.026262626262626262, \"positive_diff\": 3.0, \"negative_diff\": 245.0, \"death_diff\": null, \"positive_diff_100k\": 0.14307318336402253, \"death_diff_100k\": null, \"total_10\": 49.5}, {\"state\": \"NM\", \"date\": \"2020-03-14T00:00:00\", \"positive\": 10.0, \"negative\": 237.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 247, \"dateChecked\": \"2020-03-14T20:00:00Z\", \"ratio\": 0.04048582995951417, \"positive_diff\": 0.0, \"negative_diff\": 47.0, \"death_diff\": null, \"positive_diff_100k\": 0.0, \"death_diff_100k\": null, \"total_10\": 24.7}, {\"state\": \"NM\", \"date\": \"2020-03-13T00:00:00\", \"positive\": 10.0, \"negative\": 190.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 200, \"dateChecked\": \"2020-03-13T20:00:00Z\", \"ratio\": 0.05, \"positive_diff\": 5.0, \"negative_diff\": 35.0, \"death_diff\": null, \"positive_diff_100k\": 0.23845530560670422, \"death_diff_100k\": null, \"total_10\": 20.0}, {\"state\": \"NM\", \"date\": \"2020-03-12T00:00:00\", \"positive\": 5.0, \"negative\": 155.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 160, \"dateChecked\": \"2020-03-12T20:00:00Z\", \"ratio\": 0.03125, \"positive_diff\": 2.0, \"negative_diff\": 68.0, \"death_diff\": null, \"positive_diff_100k\": 0.0953821222426817, \"death_diff_100k\": null, \"total_10\": 16.0}, {\"state\": \"NM\", \"date\": \"2020-03-11T00:00:00\", \"positive\": 3.0, \"negative\": 87.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 90, \"dateChecked\": \"2020-03-11T20:00:00Z\", \"ratio\": 0.03333333333333333, \"positive_diff\": 3.0, \"negative_diff\": 18.0, \"death_diff\": null, \"positive_diff_100k\": 0.14307318336402253, \"death_diff_100k\": null, \"total_10\": 9.0}, {\"state\": \"NM\", \"date\": \"2020-03-10T00:00:00\", \"positive\": 0.0, \"negative\": 69.0, \"pending\": null, \"hospitalized\": null, \"death\": null, \"total\": 69, \"dateChecked\": \"2020-03-10T20:00:00Z\", \"ratio\": 0.0, \"positive_diff\": 0.0, \"negative_diff\": 12.0, \"death_diff\": null, \"positive_diff_100k\": 0.0, \"death_diff_100k\": null, \"total_10\": 6.9}, {\"state\": \"NM\", \"date\": \"2020-03-09T00:00:00\", \"positive\": 0.0, \"negative\": 57.0, \"pending\": 0.0, \"hospitalized\": null, \"death\": null, \"total\": 57, \"dateChecked\": \"2020-03-09T20:00:00Z\", \"ratio\": 0.0, \"positive_diff\": 0.0, \"negative_diff\": 9.0, \"death_diff\": null, \"positive_diff_100k\": 0.0, \"death_diff_100k\": null, \"total_10\": 5.7}, {\"state\": \"NM\", \"date\": \"2020-03-08T00:00:00\", \"positive\": 0.0, \"negative\": 48.0, \"pending\": 0.0, \"hospitalized\": null, \"death\": null, \"total\": 48, \"dateChecked\": \"2020-03-08T20:00:00Z\", \"ratio\": 0.0, \"positive_diff\": 0.0, \"negative_diff\": 0.0, \"death_diff\": null, \"positive_diff_100k\": 0.0, \"death_diff_100k\": null, \"total_10\": 4.8}, {\"state\": \"NM\", \"date\": \"2020-03-07T00:00:00\", \"positive\": 0.0, \"negative\": 48.0, \"pending\": 0.0, \"hospitalized\": null, \"death\": null, \"total\": 48, \"dateChecked\": \"2020-03-07T21:00:00Z\", \"ratio\": 0.0, \"positive_diff\": 0.0, \"negative_diff\": 32.0, \"death_diff\": null, \"positive_diff_100k\": 0.0, \"death_diff_100k\": null, \"total_10\": 4.8}, {\"state\": \"NM\", \"date\": \"2020-03-06T00:00:00\", \"positive\": 0.0, \"negative\": 16.0, \"pending\": 0.0, \"hospitalized\": null, \"death\": null, \"total\": 16, \"dateChecked\": \"2020-03-06T21:00:00Z\", \"ratio\": 0.0, \"positive_diff\": null, \"negative_diff\": null, \"death_diff\": null, \"positive_diff_100k\": null, \"death_diff_100k\": null, \"total_10\": 1.6}]}}, {\"mode\": \"vega-lite\"});\n",
       "</script>"
      ],
      "text/plain": [
       "alt.HConcatChart(...)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<p style=\"font-size: smaller\">Data Sources: \n",
       "  <a href=\"https://covidtracking.com\">The COVID Tracking Project</a>\n",
       "<br>\n",
       "Analysis and Visualization:\n",
       "  <a href=\"https://renkulab.io/projects/covid-19/covid-19-public-data\">Covid-19 Public Data Collaboration Project</a>\n",
       "</p>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# produce the charts for a few states\n",
    "\n",
    "charts=[]\n",
    "for state in ['NY', 'WA', 'NM']: \n",
    "    state_df = tdf_diff[tdf_diff['state'] == state].copy()\n",
    "\n",
    "    base = alt.Chart(state_df, title=state).encode(alt.X('date', axis=alt.Axis(title='Date'))).properties(width=250, height=150)\n",
    "    dailies = base.mark_bar(size=10).encode(alt.Y('positive_diff', axis=alt.Axis(title='Daily positive')))\n",
    "\n",
    "    totals = base.mark_line(color='red').encode(alt.Y('total_10', axis=alt.Axis(title='Total/10'))) \n",
    "    positives = totals.mark_line(color='orange').encode(alt.Y('positive', axis=alt.Axis(title='Positive')))\n",
    "    cumulative = totals + positives\n",
    "\n",
    "    ratio = base.mark_line(color='red').encode(alt.Y('ratio', axis=alt.Axis(title='Positive/Total'), scale=alt.Scale(domain=(0,1))))\n",
    "    \n",
    "    charts.append(alt.layer(dailies, cumulative).resolve_scale(y='independent'))\n",
    "\n",
    "display(alt.hconcat(*charts))\n",
    "display(html_credits)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "hide_input": true,
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}