Skip to content
Snippets Groups Projects
Commit df4e58a9 authored by Rok Roškar's avatar Rok Roškar
Browse files

add example notebook for open data ch

parent 617567cc
No related branches found
No related tags found
No related merge requests found
%% 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
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment