@@ -491,13 +491,15 @@ def fetch_one_season_from_report(url):
491
491
# The columns have the region information (i.e Pr tests, meaning this columns has the tests for the prairies)
492
492
493
493
if "reporting laboratory" in str (table .columns ):
494
+ respiratory_detection_table_exists = True
494
495
respiratory_detection_table = create_detections_table (table ,modified_date ,current_week ,current_week_end ,season [0 ])
495
496
respiratory_detection_table = respiratory_detection_table .set_index (['epiweek' , 'time_value' , 'issue' , 'geo_type' , 'geo_value' ])
496
497
elif "number" in caption .text .lower ():
497
498
number_table_exists = True
498
499
number_detections_table = create_number_detections_table (table ,modified_date ,season [0 ])
499
500
number_detections_table = number_detections_table .set_index (['epiweek' , 'time_value' , 'issue' , 'geo_type' , 'geo_value' ])
500
501
elif "positive" in caption .text .lower ():
502
+ positive_table_exists = True
501
503
flu = " influenza" in caption .text .lower ()
502
504
503
505
# tables are missing week 53
@@ -531,20 +533,21 @@ def fetch_one_season_from_report(url):
531
533
532
534
# Check if the indices are already in the season table
533
535
# If not, add the weeks tables into the season table
534
-
536
+
535
537
# check for deduplication pandas
536
- if not number_detections_table . index . isin ( all_number_tables . index ). any () :
537
- all_number_tables = pd . concat ([ all_number_tables , number_detections_table ])
538
-
539
- if not respiratory_detection_table . index . isin ( all_respiratory_detection_tables . index ). any ():
540
- all_respiratory_detection_tables = pd . concat ([ all_respiratory_detection_tables , respiratory_detection_table ])
541
-
542
- if not combined_positive_tables . index . isin ( all_positive_tables . index ). any ():
543
- all_positive_tables = pd . concat ([ all_positive_tables , combined_positive_tables ])
544
-
538
+ if respiratory_detection_table_exists :
539
+ if not respiratory_detection_table . index . isin ( all_respiratory_detection_tables . index ). any ():
540
+ all_respiratory_detection_tables = pd . concat ([ all_respiratory_detection_tables , respiratory_detection_table ])
541
+ del respiratory_detection_table
542
+ if positive_table_exists :
543
+ if not combined_positive_tables . index . isin ( all_positive_tables . index ). any ():
544
+ all_positive_tables = pd . concat ([ all_positive_tables , combined_positive_tables ])
545
+ del combined_positive_tables
546
+ del pos_table
545
547
if number_table_exists :
546
548
if not number_detections_table .index .isin (all_number_tables .index ).any ():
547
549
all_number_tables = pd .concat ([all_number_tables ,number_detections_table ])
550
+ del number_detections_table
548
551
549
552
return {
550
553
"respiratory_detection" : all_respiratory_detection_tables ,
0 commit comments