Skip to content

Commit

Permalink
NANS doctor visits:
Browse files Browse the repository at this point in the history
* write missing columns
* update test files
  • Loading branch information
dshemetov committed Apr 27, 2021
1 parent 8557308 commit a4f3dcc
Show file tree
Hide file tree
Showing 25 changed files with 14,303 additions and 14,236 deletions.
21 changes: 18 additions & 3 deletions doctor_visits/delphi_doctor_visits/update_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import pandas as pd

# first party
from delphi_utils import Nans
from .config import Config
from .geo_maps import GeoMaps
from .sensor import DoctorVisitsSensor
Expand All @@ -44,7 +45,10 @@ def write_to_csv(output_df: pd.DataFrame, geo_level, se, out_name, output_path="
out_name)
single_date_df = output_df[output_df["date"] == d]
with open(filename, "w") as outfile:
outfile.write("geo_id,val,se,direction,sample_size\n")
outfile.write(
"geo_id,val,se,direction,sample_size,"
"missing_val,missing_se,missing_sample_size\n"
)

for line in single_date_df.itertuples():
geo_id = line.geo_id
Expand All @@ -58,11 +62,22 @@ def write_to_csv(output_df: pd.DataFrame, geo_level, se, out_name, output_path="
if se:
assert sensor > 0 and se_val > 0, "p=0, std_err=0 invalid"
outfile.write(
"%s,%f,%s,%s,%s\n" % (geo_id, sensor, se_val, "NA", "NA"))
"%s,%f,%s,%s,%s,%d,%d,%d\n" %
(
geo_id, sensor, se, "NA", "NA",
Nans.NOT_MISSING, Nans.NOT_MISSING, Nans.NOT_APPLICABLE
)
)
else:
# for privacy reasons we will not report the standard error
outfile.write(
"%s,%f,%s,%s,%s\n" % (geo_id, sensor, "NA", "NA", "NA"))
"%s,%f,%s,%s,%s,%d,%d,%d\n" %
(
geo_id, sensor, "NA", "NA", "NA",
Nans.NOT_MISSING, Nans.PRIVACY, Nans.NOT_APPLICABLE
)
)

out_n += 1
logging.debug(f"wrote {out_n} rows for {geo_level}")

Expand Down

0 comments on commit a4f3dcc

Please sign in to comment.