Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Covid related series #186

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions shared_config/data_sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -2305,5 +2305,19 @@
"url" : "https://api.worldbank.org/v2/country/ZWE/indicator/NY.GDP.MKTP.KD.ZG",
"frequency" : "AS",
"tags" : ["Zimbabwe", "Inflation", "Economic", "Africa", "World Bank" ]
},
{
"title": "Global Confirmed COVID-19 Cases",
"source": "COVID_JH",
"url": "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv",
"frequency": "W",
"tags": ["World","COVID19", "Health"]
},
{
"title": "Global COVID-19 Related Deaths",
"source": "COVID_JH",
"url": "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv",
"frequency": "W",
"tags": ["World","COVID19", "Health"]
}
]
2 changes: 1 addition & 1 deletion shared_config/search_a_series.json

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions updater/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,44 @@ def download(self):
return df


class COVID_JH(DataSource):
# Downloader for COVID data from the John Hopkins github.
def download(self):
# Use read_csv to access remote file
df = pd.read_csv(
self.url,
)

df = (
df.drop(
["Province/State", "Country/Region", "Lat", "Long"], axis=1
)
.sum(axis=0)
.reset_index()
)

df["index"] = pd.to_datetime(df["index"], format="%m/%d/%y")

df = (
df.groupby([pd.Grouper(key="index", freq="W-MON")])
.mean()
.reset_index()
.sort_values("index")
)

df = (
pd.DataFrame(
df[0].values,
index=pd.to_datetime(df["index"], format="%Y-%m-%d"),
columns=["value"],
)
.diff()
.dropna()
)

return df


class ABSData(DataSource):
"""
The API data guide is avaialble here: https://www.abs.gov.au/about/data-services/application-programming-interfaces-apis/data-api-user-guide
Expand Down Expand Up @@ -265,6 +303,7 @@ def download_data(sources_path, download_path):
"Ons": Ons,
"WorldBank": WorldBankData,
"ABS": ABSData,
"COVID_JH": COVID_JH,
}

source_class = all_source_classes[data_source_dict.pop("source")]
Expand Down