-
Notifications
You must be signed in to change notification settings - Fork 0
/
covid_data_global.py
35 lines (32 loc) · 1.38 KB
/
covid_data_global.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
This is the 'covid_data_global' module.
The covid_data_global module supplies a Pandas DataFrame consisting of Covid-19
statistics on a global scale. It fetches raw data from The World Health
Organization then reduces it to a four columned DataFrame as such:
New_cases
Cumulative_cases
New_deaths
Cumulative_deaths
"""
import pandas as pd
df = pd.read_csv('https://covid19.who.int/WHO-COVID-19-global-table-data.csv',
low_memory = False)
df = df.loc[['Global']]
# df = df[df['Name'] == 'Global']
df = df[['Cases - cumulative total',\
'Cases - newly reported in last 24 hours',\
'Deaths - cumulative total',\
'Deaths - newly reported in last 24 hours']]
# df.to_csv('~/Desktop/df1.csv', index = False)
df = df.rename(columns = {'Cases - cumulative total':'Cumulative_cases',\
'Cases - newly reported in last 24 hours':'New_cases',\
'Deaths - cumulative total':'Cumulative_deaths',\
'Deaths - newly reported in last 24 hours':'New_deaths'})
# df.to_csv('~/Desktop/df2.csv', index = False)
df = df.fillna(0)
# df.to_csv('~/Desktop/df3.csv', index = False)
df = df.astype({'New_cases':'int64',\
'Cumulative_cases':'int64',\
'New_deaths':'int64',\
'Cumulative_deaths':'int64'})
# df.to_csv('~/Desktop/df4.csv', index = False)