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