18
18
import pandas as pd
19
19
20
20
# first party
21
+ from delphi_utils import Nans
21
22
from .config import Config
22
23
from .geo_maps import GeoMaps
23
24
from .sensor import DoctorVisitsSensor
@@ -44,7 +45,10 @@ def write_to_csv(output_df: pd.DataFrame, geo_level, se, out_name, output_path="
44
45
out_name )
45
46
single_date_df = output_df [output_df ["date" ] == d ]
46
47
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
+ )
48
52
49
53
for line in single_date_df .itertuples ():
50
54
geo_id = line .geo_id
@@ -58,11 +62,22 @@ def write_to_csv(output_df: pd.DataFrame, geo_level, se, out_name, output_path="
58
62
if se :
59
63
assert sensor > 0 and se_val > 0 , "p=0, std_err=0 invalid"
60
64
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
+ )
62
71
else :
63
72
# for privacy reasons we will not report the standard error
64
73
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
+
66
81
out_n += 1
67
82
logging .debug (f"wrote { out_n } rows for { geo_level } " )
68
83
0 commit comments