-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat_lab_data.py
More file actions
74 lines (67 loc) · 1.98 KB
/
format_lab_data.py
File metadata and controls
74 lines (67 loc) · 1.98 KB
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
69
70
71
72
73
74
#mcandrew
import sys
import numpy as np
import pandas as pd
if __name__ == "__main__":
#--add epiweek
lab_data = pd.read_csv("./data_sets/clinical_and_public_lab_data.csv")
lab_data["epiweek"] = [ "{:04d}{:02d}".format(x,y) for (x,y) in zip(lab_data.year.values,lab_data.week.values) ]
#--add in state abbreviation lwoer case
state_to_abbreviation = {
"Alabama": "al",
"Alaska": "ak",
"Arizona": "az",
"Arkansas": "ar",
"California": "ca",
"Colorado": "co",
"Connecticut": "ct",
"Delaware": "de",
"Florida": "fl",
"Georgia": "ga",
"Hawaii": "hi",
"Idaho": "id",
"Illinois": "il",
"Indiana": "in",
"Iowa": "ia",
"Kansas": "ks",
"Kentucky": "ky",
"Louisiana": "la",
"Maine": "me",
"Maryland": "md",
"Massachusetts": "ma",
"Michigan": "mi",
"Minnesota": "mn",
"Mississippi": "ms",
"Missouri": "mo",
"Montana": "mt",
"Nebraska": "ne",
"Nevada": "nv",
"New Hampshire": "nh",
"New Jersey": "nj",
"New Mexico": "nm",
"New York": "ny",
"North Carolina": "nc",
"North Dakota": "nd",
"Ohio": "oh",
"Oklahoma": "ok",
"Oregon": "or",
"Pennsylvania": "pa",
"Rhode Island": "ri",
"South Carolina": "sc",
"South Dakota": "sd",
"Tennessee": "tn",
"Texas": "tx",
"Utah": "ut",
"Vermont": "vt",
"Virginia": "va",
"Washington": "wa",
"West Virginia": "wv",
"Wisconsin": "wi",
"Wyoming": "wy",
"District of Columbia":"dc",
"Puerto Rico":"pr",
"National":"nat"
}
lab_data["state"] = lab_data["region"].replace(state_to_abbreviation)
lab_data = lab_data.drop(columns = "Unnamed: 0")
lab_data.to_csv("./data_sets/clinical_and_public_lab_data__formatted.csv", index=False)