Skip to content
Snippets Groups Projects
Commit e8d09f63 authored by Chandrasekhar Ramakrishnan's avatar Chandrasekhar Ramakrishnan
Browse files

feat: notebook for playing with data

parent f6f887b1
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
import pandas as pd
```
%% Cell type:markdown id: tags:
# Read in JHU CSSE data
I will switch to [xarray](http://xarray.pydata.org/en/stable/), but ATM, it's easier like this...
%% Cell type:code id: tags:
``` python
def read_jhu_covid_df(name):
filename = f"../data/covid-19_jhu-csse/time_series_19-covid-{name}.csv"
df = pd.read_csv(filename)
df = df.set_index(['Province/State', 'Country/Region', 'Lat', 'Long'])
df.columns = pd.to_datetime(df.columns)
return df
```
%% Cell type:code id: tags:
``` python
confirmed_df = read_jhu_covid_df("Confirmed")
deaths_df = read_jhu_covid_df("Deaths")
recovered_df = read_jhu_covid_df("Recovered")
```
%% Cell type:code id: tags:
``` python
def summarize_df(df, name):
ser = df.groupby(level='Country/Region').sum().iloc[:,-1].sort_values(ascending=False)
ser.name = f"Total {name}"
return ser
```
%% Cell type:code id: tags:
``` python
confirmed_ser = summarize_df(confirmed_df, "Confirmed")
deaths_ser = summarize_df(deaths_df, "Deaths")
recovered_ser = summarize_df(recovered_df, "Recovered")
```
%% Cell type:markdown id: tags:
# Read in World Bank data
%% Cell type:code id: tags:
``` python
import zipfile
zf = zipfile.ZipFile("../data/worldbank/SP.POP.TOTL.zip")
pop_df = pd.read_csv(zf.open("API_SP.POP.TOTL_DS2_en_csv_v2_821007.csv"), skiprows=4)
```
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