Skip to content

Commit f9bdf28

Browse files
committed
NANS doctor visits:
* write missing columns * update test files
1 parent 0b7103a commit f9bdf28

25 files changed

+14307
-14237
lines changed

doctor_visits/delphi_doctor_visits/update_sensor.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import pandas as pd
1818

1919
# first party
20-
from delphi_utils import Weekday
20+
from delphi_utils import Weekday, Nans
2121
from .config import Config
2222
from .geo_maps import GeoMaps
2323
from .sensor import DoctorVisitsSensor
@@ -43,7 +43,10 @@ def write_to_csv(output_df: pd.DataFrame, geo_level, se, out_name, logger, outpu
4343
out_name)
4444
single_date_df = output_df[output_df["date"] == d]
4545
with open(filename, "w") as outfile:
46-
outfile.write("geo_id,val,se,direction,sample_size\n")
46+
outfile.write(
47+
"geo_id,val,se,direction,sample_size,"
48+
"missing_val,missing_se,missing_sample_size\n"
49+
)
4750

4851
for line in single_date_df.itertuples():
4952
geo_id = line.geo_id
@@ -57,11 +60,26 @@ def write_to_csv(output_df: pd.DataFrame, geo_level, se, out_name, logger, outpu
5760
if se:
5861
assert sensor > 0 and se_val > 0, "p=0, std_err=0 invalid"
5962
outfile.write(
60-
"%s,%f,%s,%s,%s\n" % (geo_id, sensor, se_val, "NA", "NA"))
63+
"%s,%f,%s,%s,%s,%d,%d,%d\n" %
64+
(
65+
geo_id, sensor, se, "NA", "NA",
66+
Nans.NOT_MISSING.value,
67+
Nans.NOT_MISSING.value,
68+
Nans.NOT_APPLICABLE.value
69+
)
70+
)
6171
else:
6272
# for privacy reasons we will not report the standard error
6373
outfile.write(
64-
"%s,%f,%s,%s,%s\n" % (geo_id, sensor, "NA", "NA", "NA"))
74+
"%s,%f,%s,%s,%s,%d,%d,%d\n" %
75+
(
76+
geo_id, sensor, "NA", "NA", "NA",
77+
Nans.NOT_MISSING.value,
78+
Nans.CENSORED.value,
79+
Nans.NOT_APPLICABLE.value
80+
)
81+
)
82+
6583
out_n += 1
6684
logger.debug(f"wrote {out_n} rows for {geo_level}")
6785

0 commit comments

Comments
 (0)