-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexcel_analysis.py
More file actions
138 lines (87 loc) · 5.83 KB
/
excel_analysis.py
File metadata and controls
138 lines (87 loc) · 5.83 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import pandas as pd
import seaborn as sns
import numpy as np
from time import time
from matplotlib import pyplot as plt
#creating instances of all pages as tables in pandas fron excel
def a_admission_types():
start = time()
data = pd.read_excel(r"C:\Users\cadet\Desktop\MedStar TakeHome\chhs-31ea2cfd-bc1c-4bde-9626-f41b97cc1b93\emergency-department-services-trends-2013-2017.xlsx", sheet_name = "Data")
avail_24hr_df = data.filter(regex = r"(AVAIL24HRS|_adm|year)")
avail_24hr_df.dropna(how='all', axis=1, inplace=True)
avail_24hr_df.dropna(how='all', axis=0, inplace=True)
avail_on_call_df = data.filter(regex = r"(AVAIL_ON_CALL|_adm|year)")
avail_on_call_df.dropna(how='all', axis=1, inplace=True)
avail_on_call_df.dropna(how='all', axis=0, inplace=True)
list24hrs = ['ED_ANESTH_AVAIL24HRS', 'ED_LAB_SVCS_AVAIL24HRS', 'ED_OP_RM_AVAIL24HRS', 'ED_PHARM_AVAIL24HRS', 'ED_PHYSN_AVAIL24HRS',
'ED_PSYCH_ER_AVAIL24HRS', 'ED_RADIOL_SVCS_AVAIL24HRS']
list_24hr_dfs = []
for column in list24hrs:
list_24hr_dfs.append(avail_24hr_df[avail_24hr_df[column] == "YES"])
list_oncall_dfs = []
listoncall = ['ED_ANESTH_AVAIL_ON_CALL', 'ED_LAB_SVCS_AVAIL_ON_CALL', 'ED_OP_RM_AVAIL_ON_CALL', 'ED_PHARM_AVAIL_ON_CALL', 'ED_PHYSN_AVAIL_ON_CALL', 'ED_PSYCH_ER_AVAIL_ON_CALL', 'ED_RADIOL_SVCS_AVAIL_ON_CALL']
for column in listoncall:
list_oncall_dfs.append(avail_on_call_df[avail_on_call_df[column] == "YES"])
end = time() - start
print("this program took this amount of time in seconds:")
print(end)
return (list_24hr_dfs, list_oncall_dfs)
def a_ambulance_diversion_hours():
start = time()
data = pd.read_excel(r"C:\Users\cadet\Desktop\MedStar TakeHome\chhs-31ea2cfd-bc1c-4bde-9626-f41b97cc1b93\emergency-department-services-trends-2013-2017.xlsx", sheet_name = "Data")
avail_24hr_df = data.filter(regex = r"(AVAIL24HRS|_AMB_DIVERS_TOTL_HOURS|year)")
avail_24hr_df.dropna(how='all', axis=1, inplace=True)
avail_24hr_df.dropna(how='all', axis=0, inplace=True)
avail_on_call_df = data.filter(regex = r"(AVAIL_ON_CALL|_AMB_DIVERS_TOTL_HOURS|year)")
avail_on_call_df.dropna(how='all', axis=1, inplace=True)
avail_on_call_df.dropna(how='all', axis=0, inplace=True)
list24hrs = ['ED_ANESTH_AVAIL24HRS', 'ED_LAB_SVCS_AVAIL24HRS', 'ED_OP_RM_AVAIL24HRS', 'ED_PHARM_AVAIL24HRS', 'ED_PHYSN_AVAIL24HRS',
'ED_PSYCH_ER_AVAIL24HRS', 'ED_RADIOL_SVCS_AVAIL24HRS']
list_24hr_dfs = []
for column in list24hrs:
list_24hr_dfs.append(avail_24hr_df[avail_24hr_df[column] == "YES"])
list_oncall_dfs = []
listoncall = ['ED_ANESTH_AVAIL_ON_CALL', 'ED_LAB_SVCS_AVAIL_ON_CALL', 'ED_OP_RM_AVAIL_ON_CALL', 'ED_PHARM_AVAIL_ON_CALL', 'ED_PHYSN_AVAIL_ON_CALL', 'ED_PSYCH_ER_AVAIL_ON_CALL', 'ED_RADIOL_SVCS_AVAIL_ON_CALL']
for column in listoncall:
list_oncall_dfs.append(avail_on_call_df[avail_on_call_df[column] == "YES"])
print(list_oncall_dfs[0]['year'])
print(avail_24hr_df['EMS_AMB_DIVERS_TOTL_HOURS'])
end = time() - start
print("this program took this amount of time in seconds:")
print(end)
return (list_24hr_dfs, list_oncall_dfs)
def b_admission_types():
start = time()
data = pd.read_excel(r"C:\Users\cadet\Desktop\MedStar TakeHome\chhs-31ea2cfd-bc1c-4bde-9626-f41b97cc1b93\emergency-department-services-trends-2013-2017.xlsx", sheet_name = "Data")
avail_24hr_df = data.filter(regex = r"(TRAUMA_CTR|_adm|year)")
avail_24hr_df.dropna(how='all', axis=1, inplace=True)
avail_24hr_df.dropna(how='all', axis=0, inplace=True)
avail_on_call_df = data.filter(regex = r"(TRAUMA_CTR|_adm|year)")
avail_on_call_df.dropna(how='all', axis=1, inplace=True)
avail_on_call_df.dropna(how='all', axis=0, inplace=True)
ped_trauma_list = ['Level I - Pediatric', 'Level I & Level I - Ped', 'Level I & Level II - Ped', 'Level II & Level II - Ped']
non_ped_trauma_list = ['Level I', 'Level I & Level I - Ped', 'Level I & Level II - Ped', 'Level II', 'Level II & Level II - Ped', 'Level III', 'Level IV']
pediatric_trauma_df = avail_24hr_df[avail_24hr_df["TRAUMA_CTR"].isin(ped_trauma_list)]
non_pediatric_trauma_df = avail_24hr_df[avail_24hr_df["TRAUMA_CTR"].isin(non_ped_trauma_list)]
end = time() - start
print("this program took this amount of time in seconds:")
print(end)
return (pediatric_trauma_df, non_pediatric_trauma_df)
def b_ambulance_diversion_hours():
start = time()
data = pd.read_excel(r"C:\Users\cadet\Desktop\MedStar TakeHome\chhs-31ea2cfd-bc1c-4bde-9626-f41b97cc1b93\emergency-department-services-trends-2013-2017.xlsx", sheet_name = "Data")
avail_24hr_df = data.filter(regex = r"(TRAUMA_CTR|_AMB_DIVERS_TOTL_HOURS|year)")
avail_24hr_df.dropna(how='all', axis=1, inplace=True)
avail_24hr_df.dropna(how='all', axis=0, inplace=True)
avail_on_call_df = data.filter(regex = r"(TRAUMA_CTR|_AMB_DIVERS_TOTL_HOURS|year)")
avail_on_call_df.dropna(how='all', axis=1, inplace=True)
avail_on_call_df.dropna(how='all', axis=0, inplace=True)
ped_trauma_list = ['Level I - Pediatric', 'Level I & Level I - Ped', 'Level I & Level II - Ped', 'Level II & Level II - Ped']
non_ped_trauma_list = ['Level I', 'Level I & Level I - Ped', 'Level I & Level II - Ped', 'Level II', 'Level II & Level II - Ped', 'Level III', 'Level IV']
pediatric_trauma_df = avail_24hr_df[avail_24hr_df["TRAUMA_CTR"].isin(ped_trauma_list)]
non_pediatric_trauma_df = avail_24hr_df[avail_24hr_df["TRAUMA_CTR"].isin(non_ped_trauma_list)]
print(avail_24hr_df['EMS_AMB_DIVERS_TOTL_HOURS'])
end = time() - start
print("this program took this amount of time in seconds:")
print(end)
return (pediatric_trauma_df, non_pediatric_trauma_df)