File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 62
62
st .markdown (
63
63
"Projected **census** of COVID-19 patients, accounting for arrivals and discharges at Penn hospitals"
64
64
)
65
- admit_chart = admitted_patients_chart (alt = alt , census = census_df , parameters = p , as_date = as_date )
65
+ census_chart = admitted_patients_chart (alt = alt , census = census_df , parameters = p , as_date = as_date )
66
66
st .altair_chart (
67
- admit_chart , use_container_width = True
67
+ census_chart , use_container_width = True
68
68
)
69
- st .markdown (chart_descriptions (admit_chart , True ))
69
+ st .markdown (chart_descriptions (census_chart , census = True ))
70
70
if st .checkbox ("Show Projected Census in tabular form" ):
71
71
draw_census_table (st , census_df , as_date = as_date )
72
72
st .markdown (
Original file line number Diff line number Diff line change 1
1
2
2
from math import ceil
3
+ import datetime
3
4
from altair import Chart # type: ignore
4
5
import pandas as pd # type: ignore
5
6
import numpy as np # type: ignore
@@ -118,18 +119,30 @@ def additional_projections_chart(
118
119
119
120
def chart_descriptions (chart , census = False ):
120
121
messages = []
122
+
121
123
cols = ["Hospitalized" , "ICU" , "Ventilated" ]
122
124
if census :
123
125
cols = [col + " Census" for col in cols ]
126
+
124
127
asterisk = False
128
+
129
+ day = "date" if "date" in chart .data .columns else "day"
130
+
125
131
for col in cols :
126
132
if chart .data [col ].idxmax () + 1 == len (chart .data ):
127
133
asterisk = True
134
+
135
+ on = chart .data [day ][chart .data [col ].idxmax ()]
136
+ if day == "date" :
137
+ on = datetime .datetime .strftime (on , "%b %d" ) # todo: bring this to an optional arg / i18n
138
+ else :
139
+ on += 1 # 0 index issue
140
+
128
141
messages .append (
129
142
"{} peaks at {:,} on day {}{}" .format (
130
143
col ,
131
144
ceil (chart .data [col ].max ()),
132
- chart . data [ col ]. idxmax () + 1 ,
145
+ on ,
133
146
"*" if asterisk else "" ,
134
147
)
135
148
)
You can’t perform that action at this time.
0 commit comments