Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
covid-19-public-data
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christian Panse
covid-19-public-data
Commits
df4e58a9
Commit
df4e58a9
authored
5 years ago
by
Rok Roškar
Browse files
Options
Downloads
Patches
Plain Diff
add example notebook for open data ch
parent
617567cc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
notebooks/openzh-covid-19-example.ipynb
+421
-0
421 additions, 0 deletions
notebooks/openzh-covid-19-example.ipynb
with
421 additions
and
0 deletions
notebooks/openzh-covid-19-example.ipynb
0 → 100644
+
421
−
0
View file @
df4e58a9
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"\n",
"import altair as alt\n",
"import pandas as pd"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Read in the data"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# read in cantonal data and produce one dataframe\n",
"df_list = []\n",
"\n",
"for f in Path('../data/openzh-covid-19/').glob('COVID19_Fallzahlen_Kanton_*total.csv'):\n",
" df_list.append(pd.read_csv(f))\n",
"\n",
"df = pd.concat(df_list)\n",
"\n",
"df['Date'] = pd.to_datetime(df['Date'], dayfirst=True)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Date</th>\n",
" <th>Area</th>\n",
" <th>TotalTestedCases</th>\n",
" <th>TotalConfCases</th>\n",
" <th>TotalPosTests1</th>\n",
" <th>TotalCured</th>\n",
" <th>TotalDeaths</th>\n",
" <th>TotalHospitalized</th>\n",
" <th>Source</th>\n",
" <th>Source2</th>\n",
" <th>Source3</th>\n",
" <th>Unnamed: 11</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2020-03-16</td>\n",
" <td>Canton_BE</td>\n",
" <td>NaN</td>\n",
" <td>123</td>\n",
" <td>131.0</td>\n",
" <td>NaN</td>\n",
" <td>1.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2020-03-18</td>\n",
" <td>Canton_BE</td>\n",
" <td>NaN</td>\n",
" <td>193</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>1.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2020-02-27</td>\n",
" <td>Canton_BS</td>\n",
" <td>NaN</td>\n",
" <td>0</td>\n",
" <td>1.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>https://www.coronavirus.bs.ch/nm/2020-coronavi...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2020-02-28</td>\n",
" <td>Canton_BS</td>\n",
" <td>NaN</td>\n",
" <td>0</td>\n",
" <td>1.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>https://twitter.com/BR_Sprecher/status/1233316...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2020-02-29</td>\n",
" <td>Canton_BS</td>\n",
" <td>NaN</td>\n",
" <td>0</td>\n",
" <td>1.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>https://twitter.com/BAG_OFSP_UFSP/status/12337...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>2020-03-14</td>\n",
" <td>Canton_BL</td>\n",
" <td>NaN</td>\n",
" <td>47</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>2.0</td>\n",
" <td>NaN</td>\n",
" <td>https://www.baselland.ch/politik-und-behorden/...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>2020-03-15</td>\n",
" <td>Canton_BL</td>\n",
" <td>NaN</td>\n",
" <td>54</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>2.0</td>\n",
" <td>NaN</td>\n",
" <td>https://www.baselland.ch/politik-und-behorden/...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>2020-03-16</td>\n",
" <td>Canton_BL</td>\n",
" <td>NaN</td>\n",
" <td>76</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>2.0</td>\n",
" <td>NaN</td>\n",
" <td>https://www.baselland.ch/politik-und-behorden/...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>2020-03-17</td>\n",
" <td>Canton_BL</td>\n",
" <td>NaN</td>\n",
" <td>89</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>2.0</td>\n",
" <td>NaN</td>\n",
" <td>https://www.baselland.ch/politik-und-behorden/...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>2020-03-18</td>\n",
" <td>Canton_BL</td>\n",
" <td>NaN</td>\n",
" <td>116</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>2.0</td>\n",
" <td>NaN</td>\n",
" <td>https://www.baselland.ch/politik-und-behorden/...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>61 rows × 12 columns</p>\n",
"</div>"
],
"text/plain": [
" Date Area TotalTestedCases TotalConfCases TotalPosTests1 \\\n",
"0 2020-03-16 Canton_BE NaN 123 131.0 \n",
"1 2020-03-18 Canton_BE NaN 193 NaN \n",
"0 2020-02-27 Canton_BS NaN 0 1.0 \n",
"1 2020-02-28 Canton_BS NaN 0 1.0 \n",
"2 2020-02-29 Canton_BS NaN 0 1.0 \n",
".. ... ... ... ... ... \n",
"15 2020-03-14 Canton_BL NaN 47 NaN \n",
"16 2020-03-15 Canton_BL NaN 54 NaN \n",
"17 2020-03-16 Canton_BL NaN 76 NaN \n",
"18 2020-03-17 Canton_BL NaN 89 NaN \n",
"19 2020-03-18 Canton_BL NaN 116 NaN \n",
"\n",
" TotalCured TotalDeaths TotalHospitalized \\\n",
"0 NaN 1.0 NaN \n",
"1 NaN 1.0 NaN \n",
"0 NaN NaN NaN \n",
"1 NaN NaN NaN \n",
"2 NaN NaN NaN \n",
".. ... ... ... \n",
"15 NaN 2.0 NaN \n",
"16 NaN 2.0 NaN \n",
"17 NaN 2.0 NaN \n",
"18 NaN 2.0 NaN \n",
"19 NaN 2.0 NaN \n",
"\n",
" Source Source2 Source3 \\\n",
"0 NaN NaN NaN \n",
"1 NaN NaN NaN \n",
"0 https://www.coronavirus.bs.ch/nm/2020-coronavi... NaN NaN \n",
"1 https://twitter.com/BR_Sprecher/status/1233316... NaN NaN \n",
"2 https://twitter.com/BAG_OFSP_UFSP/status/12337... NaN NaN \n",
".. ... ... ... \n",
"15 https://www.baselland.ch/politik-und-behorden/... NaN NaN \n",
"16 https://www.baselland.ch/politik-und-behorden/... NaN NaN \n",
"17 https://www.baselland.ch/politik-und-behorden/... NaN NaN \n",
"18 https://www.baselland.ch/politik-und-behorden/... NaN NaN \n",
"19 https://www.baselland.ch/politik-und-behorden/... NaN NaN \n",
"\n",
" Unnamed: 11 \n",
"0 NaN \n",
"1 NaN \n",
"0 NaN \n",
"1 NaN \n",
"2 NaN \n",
".. ... \n",
"15 NaN \n",
"16 NaN \n",
"17 NaN \n",
"18 NaN \n",
"19 NaN \n",
"\n",
"[61 rows x 12 columns]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# display the dataframe\n",
"df"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Plot the available data"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"<div id=\"altair-viz-61141442a2d542d2919ca84809825792\"></div>\n",
"<script type=\"text/javascript\">\n",
" (function(spec, embedOpt){\n",
" const outputDiv = document.getElementById(\"altair-viz-61141442a2d542d2919ca84809825792\");\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}}, \"data\": {\"name\": \"data-4aee0f5f3a635fed9abd9b652c303e85\"}, \"mark\": \"line\", \"encoding\": {\"color\": {\"type\": \"nominal\", \"field\": \"Area\"}, \"x\": {\"type\": \"temporal\", \"field\": \"Date\"}, \"y\": {\"type\": \"quantitative\", \"field\": \"TotalConfCases\"}}, \"$schema\": \"https://vega.github.io/schema/vega-lite/v4.0.2.json\", \"datasets\": {\"data-4aee0f5f3a635fed9abd9b652c303e85\": [{\"Date\": \"2020-03-16T00:00:00\", \"Area\": \"Canton_BE\", \"TotalTestedCases\": null, \"TotalConfCases\": 123, \"TotalPosTests1\": 131.0, \"TotalCured\": null, \"TotalDeaths\": 1.0, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-18T00:00:00\", \"Area\": \"Canton_BE\", \"TotalTestedCases\": null, \"TotalConfCases\": 193, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": 1.0, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-02-27T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 0, \"TotalPosTests1\": 1.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://www.coronavirus.bs.ch/nm/2020-coronavirus-erster-positiver-fall-in-basel-stadt-zweiter-positiv-getesteter-ausserkantonaler-fall-gd.html\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-02-28T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 0, \"TotalPosTests1\": 1.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://twitter.com/BR_Sprecher/status/1233316679863631873?s=20\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-02-29T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 0, \"TotalPosTests1\": 1.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://twitter.com/BAG_OFSP_UFSP/status/1233759578241863681?s=20\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-01T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 1, \"TotalPosTests1\": 0.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://www.coronavirus.bs.ch/nm/2020-coronavirus-anzahl-der-getesteten-faelle-und-zwischenstand-kita-riehen-gd.html\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-02T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": 235.0, \"TotalConfCases\": 3, \"TotalPosTests1\": 0.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://www.coronavirus.bs.ch/nm/2020-coronavirus-zwei-neue-positive-faelle-in-basel-stadt-gd.html\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-03T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 3, \"TotalPosTests1\": 0.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://twitter.com/BAG_OFSP_UFSP/status/1234880556095213569?s=20\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-04T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 3, \"TotalPosTests1\": 0.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://twitter.com/BAG_OFSP_UFSP/status/1235240377134862336?s=20\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-05T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 8, \"TotalPosTests1\": 0.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://www.coronavirus.bs.ch/nm/2020-coronavirus-fuenf-neue-positive-faelle-in-basel-stadt-gd.html\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-06T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 15, \"TotalPosTests1\": 2.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://twitter.com/BAG_OFSP_UFSP/status/1235934884167852035?s=20\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-07T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 21, \"TotalPosTests1\": 1.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://twitter.com/BAG_OFSP_UFSP/status/1236249864473894914?s=20\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-08T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 24, \"TotalPosTests1\": 1.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://twitter.com/BAG_OFSP_UFSP/status/1236609191831384064?s=20\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-09T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 28, \"TotalPosTests1\": 1.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://twitter.com/BAG_OFSP_UFSP/status/1236973685602426881?s=20\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-10T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 33, \"TotalPosTests1\": 0.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://twitter.com/BAG_OFSP_UFSP/status/1237336196772175873?s=20\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-11T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 37, \"TotalPosTests1\": 12.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://twitter.com/BAG_OFSP_UFSP/status/1237694819419422720?s=20\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-12T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 73, \"TotalPosTests1\": 7.0, \"TotalCured\": 4.0, \"TotalDeaths\": 1.0, \"TotalHospitalized\": null, \"Source\": \"https://twitter.com/BAG_OFSP_UFSP/status/1238073089902235648?s=20\", \"Source2\": \"https://www.coronavirus.bs.ch/nm/2020-coronavirus-ende-der-quarantaenemassnahmen-im-fall-kita-riehen-gd.html\", \"Source3\": \"https://www.coronavirus.bs.ch/nm/2020-coronavirus-erster-todesfall-im-kanton-basel-stadt-gd.html\", \"Unnamed: 11\": null}, {\"Date\": \"2020-03-13T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 92, \"TotalPosTests1\": 19.0, \"TotalCured\": null, \"TotalDeaths\": 1.0, \"TotalHospitalized\": null, \"Source\": \"https://twitter.com/BAG_OFSP_UFSP/status/1238430659762364417?s=20\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-14T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 100, \"TotalPosTests1\": 19.0, \"TotalCured\": null, \"TotalDeaths\": 1.0, \"TotalHospitalized\": null, \"Source\": \"https://twitter.com/BAG_OFSP_UFSP/status/1238773726423941127?s=20\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-16T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 144, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": 4.0, \"TotalHospitalized\": null, \"Source\": \"https://www.coronavirus.bs.ch/nm/2020-tagesbulletin-coronavirus-144-bestaetigte-faelle-im-kanton-basel-stadt-gd.html\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-17T00:00:00\", \"Area\": \"Canton_BS\", \"TotalTestedCases\": null, \"TotalConfCases\": 165, \"TotalPosTests1\": null, \"TotalCured\": 25.0, \"TotalDeaths\": 4.0, \"TotalHospitalized\": 30.0, \"Source\": \"https://www.coronavirus.bs.ch/nm/2020-tagesbulletin-coronavirus-165-bestaetigte-faelle-im-kanton-basel-stadt-gd.html\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-18T00:00:00\", \"Area\": \"Canton_BS\\t\", \"TotalTestedCases\": null, \"TotalConfCases\": 182, \"TotalPosTests1\": null, \"TotalCured\": 36.0, \"TotalDeaths\": 4.0, \"TotalHospitalized\": 40.0, \"Source\": \"https://www.coronavirus.bs.ch/nm/2020-tagesbulletin-coronavirus-182-bestaetigte-faelle-im-kanton-basel-stadt-treffen-mit-allen-spitaelern-gd.html\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-02-27T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": null, \"TotalConfCases\": 1, \"TotalPosTests1\": 1.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-02-28T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": null, \"TotalConfCases\": 2, \"TotalPosTests1\": 2.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-02T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": null, \"TotalConfCases\": 2, \"TotalPosTests1\": 9.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-03T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": 400.0, \"TotalConfCases\": 9, \"TotalPosTests1\": 13.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-05T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": null, \"TotalConfCases\": 19, \"TotalPosTests1\": 19.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-06T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": null, \"TotalConfCases\": 26, \"TotalPosTests1\": 26.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-07T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": null, \"TotalConfCases\": 30, \"TotalPosTests1\": 30.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-08T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": null, \"TotalConfCases\": 37, \"TotalPosTests1\": 37.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-09T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": 855.0, \"TotalConfCases\": 40, \"TotalPosTests1\": 40.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-10T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": null, \"TotalConfCases\": 49, \"TotalPosTests1\": 49.0, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-11T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": null, \"TotalConfCases\": 59, \"TotalPosTests1\": 59.0, \"TotalCured\": 1.0, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-12T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": null, \"TotalConfCases\": 92, \"TotalPosTests1\": null, \"TotalCured\": 7.0, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-13T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": null, \"TotalConfCases\": 140, \"TotalPosTests1\": null, \"TotalCured\": 11.0, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-16T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": null, \"TotalConfCases\": 270, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": 1.0, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-17T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": null, \"TotalConfCases\": 294, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-18T00:00:00\", \"Area\": \"Canton_ZH\", \"TotalTestedCases\": null, \"TotalConfCases\": 424, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-16T00:00:00\", \"Area\": \"Canton_TG\", \"TotalTestedCases\": 246.0, \"TotalConfCases\": 17, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-17T00:00:00\", \"Area\": \"Canton_TG\", \"TotalTestedCases\": 276.0, \"TotalConfCases\": 23, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-18T00:00:00\", \"Area\": \"Canton_TG\", \"TotalTestedCases\": null, \"TotalConfCases\": 32, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-02-28T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 1, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/medienmitteilungen/neuer-coronavirus-covid-19-erster-bestaetigter-fall-aus-dem-kanton-basel-landschaft\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-02-29T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 2, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/medienmitteilungen/weiterer-bestaetigter-fall-aus-dem-kanton-basel-landschaft\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-01T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 2, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-02T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 2, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-03T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 2, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-04T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 2, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-05T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 6, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/medienmitteilungen/neuer-coronavirus-covid-19-sechs-bestaetigte-faelle-im-kanton-basel-landschaft\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-06T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 6, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-07T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 15, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": null, \"TotalHospitalized\": null, \"Source\": \"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/medienmitteilungen/update-15-bestaetigte-faelle-in-basel-landschaft\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-08T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 19, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": 1.0, \"TotalHospitalized\": null, \"Source\": \"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/medienmitteilungen/patient-im-kantonsspital-baselland-stirbt-an-den-folgen-einer-coronavirus-infektion\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-09T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 20, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": 1.0, \"TotalHospitalized\": null, \"Source\": \"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/medienmitteilungen/update-xx-bestaetigte-faelle-in-basel-landschaft\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-10T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 22, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": 1.0, \"TotalHospitalized\": null, \"Source\": \"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/medienmitteilungen/update\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-11T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 26, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": 2.0, \"TotalHospitalized\": null, \"Source\": \"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/medienmitteilungen/update-26-bestaetigte-faelle-in-basel-landschaft-1\", \"Source2\": \"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/medienmitteilungen/zweiter-baselbieter-patient-stirbt-an-den-folgen-einer-covid-19-infektion\", \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-12T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 26, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": 2.0, \"TotalHospitalized\": null, \"Source\": null, \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-13T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 42, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": 2.0, \"TotalHospitalized\": null, \"Source\": \"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/medienmitteilungen/update-26-bestaetigte-faelle-in-basel-landschaft-2\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-14T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 47, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": 2.0, \"TotalHospitalized\": null, \"Source\": \"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/medienmitteilungen/update-47-bestaetigte-faelle-in-basel-landschaft\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-15T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 54, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": 2.0, \"TotalHospitalized\": null, \"Source\": \"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/medienmitteilungen/update-54-bestaetigte-faelle-in-basel-landschaft\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-16T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 76, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": 2.0, \"TotalHospitalized\": null, \"Source\": \"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/medienmitteilungen/update-67-bestaetigte-faelle-in-basel-landschaft\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-17T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 89, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": 2.0, \"TotalHospitalized\": null, \"Source\": \"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/medienmitteilungen/update-89-bestaetigte-faelle-in-basel-landschaft\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}, {\"Date\": \"2020-03-18T00:00:00\", \"Area\": \"Canton_BL\", \"TotalTestedCases\": null, \"TotalConfCases\": 116, \"TotalPosTests1\": null, \"TotalCured\": null, \"TotalDeaths\": 2.0, \"TotalHospitalized\": null, \"Source\": \"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/medienmitteilungen/update-116-bestaetigte-faelle-in-basel-landschaft\", \"Source2\": null, \"Source3\": null, \"Unnamed: 11\": null}]}}, {\"mode\": \"vega-lite\"});\n",
"</script>"
],
"text/plain": [
"alt.Chart(...)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"alt.Chart(df).mark_line().encode(x='Date', y='TotalConfCases', color='Area')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
%% Cell type:code id: tags:
```
python
from
pathlib
import
Path
import
altair
as
alt
import
pandas
as
pd
```
%% Cell type:markdown id: tags:
## Read in the data
%% Cell type:code id: tags:
```
python
# read in cantonal data and produce one dataframe
df_list
=
[]
for
f
in
Path
(
'
../data/openzh-covid-19/
'
).
glob
(
'
COVID19_Fallzahlen_Kanton_*total.csv
'
):
df_list
.
append
(
pd
.
read_csv
(
f
))
df
=
pd
.
concat
(
df_list
)
df
[
'
Date
'
]
=
pd
.
to_datetime
(
df
[
'
Date
'
],
dayfirst
=
True
)
```
%% Cell type:code id: tags:
```
python
# display the dataframe
df
```
%% Output
Date Area TotalTestedCases TotalConfCases TotalPosTests1 \
0 2020-03-16 Canton_BE NaN 123 131.0
1 2020-03-18 Canton_BE NaN 193 NaN
0 2020-02-27 Canton_BS NaN 0 1.0
1 2020-02-28 Canton_BS NaN 0 1.0
2 2020-02-29 Canton_BS NaN 0 1.0
.. ... ... ... ... ...
15 2020-03-14 Canton_BL NaN 47 NaN
16 2020-03-15 Canton_BL NaN 54 NaN
17 2020-03-16 Canton_BL NaN 76 NaN
18 2020-03-17 Canton_BL NaN 89 NaN
19 2020-03-18 Canton_BL NaN 116 NaN
TotalCured TotalDeaths TotalHospitalized \
0 NaN 1.0 NaN
1 NaN 1.0 NaN
0 NaN NaN NaN
1 NaN NaN NaN
2 NaN NaN NaN
.. ... ... ...
15 NaN 2.0 NaN
16 NaN 2.0 NaN
17 NaN 2.0 NaN
18 NaN 2.0 NaN
19 NaN 2.0 NaN
Source Source2 Source3 \
0 NaN NaN NaN
1 NaN NaN NaN
0 https://www.coronavirus.bs.ch/nm/2020-coronavi... NaN NaN
1 https://twitter.com/BR_Sprecher/status/1233316... NaN NaN
2 https://twitter.com/BAG_OFSP_UFSP/status/12337... NaN NaN
.. ... ... ...
15 https://www.baselland.ch/politik-und-behorden/... NaN NaN
16 https://www.baselland.ch/politik-und-behorden/... NaN NaN
17 https://www.baselland.ch/politik-und-behorden/... NaN NaN
18 https://www.baselland.ch/politik-und-behorden/... NaN NaN
19 https://www.baselland.ch/politik-und-behorden/... NaN NaN
Unnamed: 11
0 NaN
1 NaN
0 NaN
1 NaN
2 NaN
.. ...
15 NaN
16 NaN
17 NaN
18 NaN
19 NaN
[61 rows x 12 columns]
%% Cell type:markdown id: tags:
## Plot the available data
%% Cell type:code id: tags:
```
python
alt
.
Chart
(
df
).
mark_line
().
encode
(
x
=
'
Date
'
,
y
=
'
TotalConfCases
'
,
color
=
'
Area
'
)
```
%% Output
alt.Chart(...)
%% Cell type:code id: tags:
```
python
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment