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,26 @@ 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 .value ,
69
+ Nans .NOT_MISSING .value ,
70
+ Nans .NOT_APPLICABLE .value
71
+ )
72
+ )
62
73
else :
63
74
# for privacy reasons we will not report the standard error
64
75
outfile .write (
65
- "%s,%f,%s,%s,%s\n " % (geo_id , sensor , "NA" , "NA" , "NA" ))
76
+ "%s,%f,%s,%s,%s,%d,%d,%d\n " %
77
+ (
78
+ geo_id , sensor , "NA" , "NA" , "NA" ,
79
+ Nans .NOT_MISSING .value ,
80
+ Nans .PRIVACY .value ,
81
+ Nans .NOT_APPLICABLE .value
82
+ )
83
+ )
84
+
66
85
out_n += 1
67
86
logging .debug (f"wrote { out_n } rows for { geo_level } " )
68
87
0 commit comments