@@ -73,6 +73,13 @@ def check_date_format(date_string):
7373
7474 return (new_date )
7575
76+ def convert_date_to_int (date_string ):
77+ if re .search ("[0-9]{4}-[0-9]{2}-[0-9]{2}" ,str (date_string )):
78+ new_date = int (re .sub ("-" ,"" ,str (date_string )))
79+ else :
80+ new_date = date_string
81+ return (new_date )
82+
7683def get_dashboard_update_date (base_url ,headers ):
7784 # Get update date
7885 update_date_url = base_url + "RVD_UpdateDate.csv"
@@ -206,6 +213,11 @@ def get_positive_data(base_url,headers,update_date):
206213 assert all ([0 <= val <= 100 or math .isnan (val ) for val in df [df .columns [k ]]]), "Percentage not from 0-100"
207214
208215 df = df .reset_index ()
216+
217+ # convert dates to integers
218+ df ['time_value' ] = [convert_date_to_int (t ) for t in df ['time_value' ]]
219+ df ['issue' ] = [convert_date_to_int (t ) for t in df ['issue' ]]
220+
209221 return (df .set_index (['epiweek' , 'time_value' , 'issue' , 'geo_type' , 'geo_value' ],verify_integrity = True ))
210222
211223def get_detections_data (base_url ,headers ,update_date ):
@@ -243,6 +255,10 @@ def get_detections_data(base_url,headers,update_date):
243255 df_detections = df_detections .rename (columns = {'reportinglaboratory' :"geo_value" ,'date' :"time_value" })
244256 df_detections ['geo_value' ] = [abbreviate_geo (g ) for g in df_detections ['geo_value' ]]
245257 df_detections ['geo_type' ] = [create_geo_types (g ,"lab" ) for g in df_detections ['geo_value' ]]
258+
259+ # convert dates to integers
260+ df_detections ['time_value' ] = [convert_date_to_int (t ) for t in df_detections ['time_value' ]]
261+ df_detections ['issue' ] = [convert_date_to_int (t ) for t in df_detections ['issue' ]]
246262
247263 return (df_detections .set_index (['epiweek' , 'time_value' , 'issue' , 'geo_type' , 'geo_value' ],verify_integrity = True ))
248264
@@ -336,13 +352,13 @@ def combine_tables(data_dict):
336352 detections = data_dict ["respiratory_detection" ]
337353
338354 positive ["epiweek" ] = pd .to_numeric (positive ["epiweek" ],downcast = "integer" )
339- positive ["time_value" ] = pd .to_datetime (positive ["time_value" ])
340- positive ["issue" ] = pd .to_datetime (positive ["issue" ])
355+ # positive["time_value"] = pd.to_datetime(positive["time_value"])
356+ # positive["issue"] = pd.to_datetime(positive["issue"])
341357 positive ['geo_type' ] = [create_geo_types (g ,'lab' ) for g in positive ['geo_value' ]]
342358
343359 detections ["epiweek" ] = pd .to_numeric (detections ["epiweek" ],downcast = "integer" )
344- detections ["time_value" ] = pd .to_datetime (detections ["time_value" ])
345- detections ["issue" ] = pd .to_datetime (detections ["issue" ])
360+ # detections["time_value"] = pd.to_datetime(detections["time_value"])
361+ # detections["issue"] = pd.to_datetime(detections["issue"])
346362 detections ['geo_type' ] = [create_geo_types (g ,'lab' ) for g in detections ['geo_value' ]]
347363
348364 detections = expand_detections_columns (detections )
0 commit comments