-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_covid_numbers.py
69 lines (65 loc) · 2.05 KB
/
update_covid_numbers.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import numpy as np
import pandas as pd
states = {
'AK': 'Alaska',
'AL': 'Alabama',
'AR': 'Arkansas',
'AZ': 'Arizona',
'CA': 'California',
'CO': 'Colorado',
'CT': 'Connecticut',
'DC': 'District of Columbia',
'DE': 'Delaware',
'FL': 'Florida',
'GA': 'Georgia',
'HI': 'Hawaii',
'IA': 'Iowa',
'ID': 'Idaho',
'IL': 'Illinois',
'IN': 'Indiana',
'KS': 'Kansas',
'KY': 'Kentucky',
'LA': 'Louisiana',
'MA': 'Massachusetts',
'MD': 'Maryland',
'ME': 'Maine',
'MI': 'Michigan',
'MN': 'Minnesota',
'MO': 'Missouri',
'MS': 'Mississippi',
'MT': 'Montana',
'NA': 'National',
'NC': 'North Carolina',
'ND': 'North Dakota',
'NE': 'Nebraska',
'NH': 'New Hampshire',
'NJ': 'New Jersey',
'NM': 'New Mexico',
'NV': 'Nevada',
'NY': 'New York',
'OH': 'Ohio',
'OK': 'Oklahoma',
'OR': 'Oregon',
'PA': 'Pennsylvania',
'RI': 'Rhode Island',
'SC': 'South Carolina',
'SD': 'South Dakota',
'TN': 'Tennessee',
'TX': 'Texas',
'UT': 'Utah',
'VA': 'Virginia',
'VT': 'Vermont',
'WA': 'Washington',
'WI': 'Wisconsin',
'WV': 'West Virginia',
'WY': 'Wyoming'
}
untracked_territories = ['AS', 'MP', 'VI', 'PR', 'GU']
df_new = pd.read_csv('https://api.covidtracking.com/v1/states/current.csv')
df_new['state'] = df_new['state'].apply(lambda r: states[r] if r not in untracked_territories else r)
df_new = df_new[~df_new['state'].isin(untracked_territories)].reset_index()
df_new = df_new[['state', 'positive', 'death', 'totalTestResults']]
df_new.columns = ['State', 'Infected', 'Deaths', 'Tested']
df_prod = pd.read_csv('./prod/COVID19_state.csv')
df_prod['Tested'], df_prod['Infected'], df_prod['Deaths'] = df_new['Tested'], df_new['Infected'], df_new['Deaths']
df_prod.to_csv('./prod/COVID19_state.csv', index=False)