Skip to content

Commit

Permalink
Merge pull request #701 from hxchua/covid19_sg
Browse files Browse the repository at this point in the history
Covid19 Singapore Data
  • Loading branch information
rneher committed May 25, 2020
2 parents 3a30ef3 + 1b3ec31 commit 5fdbf45
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
49 changes: 49 additions & 0 deletions data/parsers/singapore.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
"""
Created on Sat May 23 23:15:07 2020
@author: hxchua
"""

import sys
import requests
import csv
import io
from datetime import datetime
import pandas as pd

from .utils import store_data, stoi

# ------------------------------------------------------------------------
# Globals

URL = "https://raw.githubusercontent.com/hxchua/datadoubleconfirm/master/datasets/covid19_sg.csv"
cols = ['time', 'cases', 'deaths', 'hospitalized', 'icu', 'recovered']

# ------------------------------------------------------------------------
# Main point of entry

def parse():
r = requests.get(URL)
if not r.ok:
print(f"Failed to fetch {URL}", file=sys.stderr)
exit(1)
r.close()
sg_data = dict(Singapore=[])

df = pd.read_csv(URL)

df.loc[df['Date'] <= '2020-03-19', 'hosp_cleaned'] = df['Still_Hospitalised'] - df['Intensive_Care_Unit_(ICU)']
df.loc[df['Date'] > '2020-03-19', 'hosp_cleaned'] = df['General_Wards_MOH_report']

for i in range(0,df.shape[0]):
date_str = df['Date'][i]
num_cases = df['Cumulative_Confirmed'][i]
num_deaths = df['Cumulative_Deaths'][i]
num_hosp = df['hosp_cleaned'][i].astype(int)
num_icus = df['Intensive_Care_Unit_(ICU)'][i]
num_recovered = df['Cumulative_Discharged'][i]

sg_data["Singapore"].append([date_str, num_cases, num_deaths, num_hosp, num_icus, num_recovered])

store_data(sg_data, 'singapore', cols)
5 changes: 5 additions & 0 deletions data/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
"dataProvenance": "https://www.mhlw.go.jp/stf/seisakunitsuite/bunya/0000121431_00086.html",
"license": "MIT license"
},
"singapore": {
"primarySource": "https://github.com/hxchua/datadoubleconfirm/blob/master/datasets/covid19_sg.csv",
"dataProvenance": "https://data.world/hxchua/covid-19-singapore",
"license": "MIT license"
},
"ecdc": {
"primarySource": "https://www.ecdc.europa.eu/sites/default/files/documents/COVID-19-geographic-disbtribution-worldwide-<DATE>-xlsx",
"dataProvenance": "European Centre for Disease Prevention and Control",
Expand Down

1 comment on commit 5fdbf45

@vercel
Copy link

@vercel vercel bot commented on 5fdbf45 May 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.