@@ -74,3 +74,51 @@ def get_dispositions(
74
74
) -> Tuple [np .ndarray , ...]:
75
75
"""Get dispositions of infected adjusted by rate and market_share."""
76
76
return (* (infected * rate * market_share for rate in rates ),)
77
+
78
+
79
+
80
+ def build_admissions_df (p ) -> pd .DataFrame :
81
+ """Build admissions dataframe from Parameters."""
82
+ days = np .array (range (0 , p .n_days + 1 ))
83
+ data_dict = dict (zip (["day" , "Hospitalized" , "ICU" , "Ventilated" ],
84
+ [days ] + [disposition for disposition in p .dispositions ]
85
+ ))
86
+ projection = pd .DataFrame .from_dict (data_dict )
87
+ # New cases
88
+ projection_admits = projection .iloc [:- 1 , :] - projection .shift (1 )
89
+ projection_admits [projection_admits < 0 ] = 0
90
+ projection_admits ["day" ] = range (projection_admits .shape [0 ])
91
+ return projection_admits
92
+
93
+
94
+ def build_census_df (
95
+ projection_admits : pd .DataFrame ,
96
+ parameters
97
+ ) -> pd .DataFrame :
98
+ """ALOS for each category of COVID-19 case (total guesses)"""
99
+ n_days = np .shape (projection_admits )[0 ]
100
+ hosp_los , icu_los , vent_los = parameters .lengths_of_stay
101
+ los_dict = {
102
+ "Hospitalized" : hosp_los ,
103
+ "ICU" : icu_los ,
104
+ "Ventilated" : vent_los ,
105
+ }
106
+
107
+ census_dict = dict ()
108
+ for k , los in los_dict .items ():
109
+ census = (
110
+ projection_admits .cumsum ().iloc [:- los , :]
111
+ - projection_admits .cumsum ().shift (los ).fillna (0 )
112
+ ).apply (np .ceil )
113
+ census_dict [k ] = census [k ]
114
+
115
+ census_df = pd .DataFrame (census_dict )
116
+ census_df ["day" ] = census_df .index
117
+ census_df = census_df [["day" , "Hospitalized" , "ICU" , "Ventilated" ]]
118
+ census_df = census_df .head (n_days )
119
+ census_df = census_df .rename (
120
+ columns = {disposition : f"{ disposition } Census"
121
+ for disposition
122
+ in ("Hospitalized" , "ICU" , "Ventilated" )}
123
+ )
124
+ return census_df
0 commit comments