Skip to content

Commit a4f3dcc

Browse files
committed
NANS doctor visits:
* write missing columns * update test files
1 parent 8557308 commit a4f3dcc

25 files changed

+14303
-14236
lines changed

doctor_visits/delphi_doctor_visits/update_sensor.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import pandas as pd
1919

2020
# first party
21+
from delphi_utils import Nans
2122
from .config import Config
2223
from .geo_maps import GeoMaps
2324
from .sensor import DoctorVisitsSensor
@@ -44,7 +45,10 @@ def write_to_csv(output_df: pd.DataFrame, geo_level, se, out_name, output_path="
4445
out_name)
4546
single_date_df = output_df[output_df["date"] == d]
4647
with open(filename, "w") as outfile:
47-
outfile.write("geo_id,val,se,direction,sample_size\n")
48+
outfile.write(
49+
"geo_id,val,se,direction,sample_size,"
50+
"missing_val,missing_se,missing_sample_size\n"
51+
)
4852

4953
for line in single_date_df.itertuples():
5054
geo_id = line.geo_id
@@ -58,11 +62,22 @@ def write_to_csv(output_df: pd.DataFrame, geo_level, se, out_name, output_path="
5862
if se:
5963
assert sensor > 0 and se_val > 0, "p=0, std_err=0 invalid"
6064
outfile.write(
61-
"%s,%f,%s,%s,%s\n" % (geo_id, sensor, se_val, "NA", "NA"))
65+
"%s,%f,%s,%s,%s,%d,%d,%d\n" %
66+
(
67+
geo_id, sensor, se, "NA", "NA",
68+
Nans.NOT_MISSING, Nans.NOT_MISSING, Nans.NOT_APPLICABLE
69+
)
70+
)
6271
else:
6372
# for privacy reasons we will not report the standard error
6473
outfile.write(
65-
"%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, Nans.PRIVACY, Nans.NOT_APPLICABLE
78+
)
79+
)
80+
6681
out_n += 1
6782
logging.debug(f"wrote {out_n} rows for {geo_level}")
6883

0 commit comments

Comments
 (0)