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

zh open data notebook update

parent 21c0e7b8
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
from pathlib import Path from pathlib import Path
import altair as alt import altair as alt
import pandas as pd import pandas as pd
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Read in the data ## Read in the data
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# read in cantonal data and produce one dataframe # read in cantonal data and produce one dataframe
df_list = [] df_list = []
for f in Path('../../data/openzh-covid-19/').glob('COVID19_Fallzahlen_Kanton_*total.csv'): for f in Path('../../data/openzh-covid-19/').glob('COVID19_Fallzahlen_Kanton_*total.csv'):
df_list.append(pd.read_csv(f)) df_list.append(pd.read_csv(f))
df = pd.concat(df_list) df = pd.concat(df_list)
df['Date'] = pd.to_datetime(df['Date'], dayfirst=True) df['Date'] = pd.to_datetime(df['Date'], dayfirst=True)
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# display the dataframe # display the dataframe
df df
``` ```
%% Output %% Output
Date Area TotalTestedCases TotalConfCases TotalPosTests1 \ Date Area TotalTestedCases TotalConfCases TotalPosTests1 \
0 2020-03-16 Canton_BE NaN 123 131.0 0 2020-03-16 Canton_BE NaN 123 131.0
1 2020-03-18 Canton_BE NaN 193 NaN 1 2020-03-18 Canton_BE NaN 193 NaN
0 2020-02-28 Canton_BL NaN 1 NaN 0 2020-02-28 Canton_BL NaN 1 NaN
1 2020-02-29 Canton_BL NaN 2 NaN 1 2020-02-29 Canton_BL NaN 2 NaN
2 2020-03-01 Canton_BL NaN 2 NaN 2 2020-03-01 Canton_BL NaN 2 NaN
.. ... ... ... ... ... .. ... ... ... ... ...
11 2020-03-12 Canton_ZH NaN 92 NaN 11 2020-03-12 Canton_ZH NaN 92 NaN
12 2020-03-13 Canton_ZH NaN 140 NaN 12 2020-03-13 Canton_ZH NaN 140 NaN
13 2020-03-16 Canton_ZH NaN 270 NaN 13 2020-03-16 Canton_ZH NaN 270 NaN
14 2020-03-17 Canton_ZH NaN 294 NaN 14 2020-03-17 Canton_ZH NaN 294 NaN
15 2020-03-18 Canton_ZH NaN 424 NaN 15 2020-03-18 Canton_ZH NaN 424 NaN
TotalCured TotalDeaths TotalHospitalized \ TotalCured TotalDeaths TotalHospitalized \
0 NaN 1.0 NaN 0 NaN 1.0 NaN
1 NaN 1.0 NaN 1 NaN 1.0 NaN
0 NaN NaN NaN 0 NaN NaN NaN
1 NaN NaN NaN 1 NaN NaN NaN
2 NaN NaN NaN 2 NaN NaN NaN
.. ... ... ... .. ... ... ...
11 7.0 NaN NaN 11 7.0 NaN NaN
12 11.0 NaN NaN 12 11.0 NaN NaN
13 NaN 1.0 NaN 13 NaN 1.0 NaN
14 NaN NaN NaN 14 NaN NaN NaN
15 NaN NaN NaN 15 NaN NaN NaN
Source Source2 Source3 \ Source Source2 Source3 \
0 NaN NaN NaN 0 NaN NaN NaN
1 NaN NaN NaN 1 NaN NaN NaN
0 https://www.baselland.ch/politik-und-behorden/... NaN NaN 0 https://www.baselland.ch/politik-und-behorden/... NaN NaN
1 https://www.baselland.ch/politik-und-behorden/... NaN NaN 1 https://www.baselland.ch/politik-und-behorden/... NaN NaN
2 NaN NaN NaN 2 NaN NaN NaN
.. ... ... ... .. ... ... ...
11 NaN NaN NaN 11 NaN NaN NaN
12 NaN NaN NaN 12 NaN NaN NaN
13 NaN NaN NaN 13 NaN NaN NaN
14 NaN NaN NaN 14 NaN NaN NaN
15 NaN NaN NaN 15 NaN NaN NaN
Unnamed: 11 Unnamed: 11
0 NaN 0 NaN
1 NaN 1 NaN
0 NaN 0 NaN
1 NaN 1 NaN
2 NaN 2 NaN
.. ... .. ...
11 NaN 11 NaN
12 NaN 12 NaN
13 NaN 13 NaN
14 NaN 14 NaN
15 NaN 15 NaN
[61 rows x 12 columns] [75 rows x 12 columns]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Plot the available data ## Plot the available data
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
alt.Chart(df).mark_line().encode(x='Date', y='TotalConfCases', color='Area') alt.Chart(df).mark_line().encode(x='Date', y='TotalConfCases', color='Area')
``` ```
%% Output %% Output
alt.Chart(...) 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