@@ -1389,13 +1389,19 @@ def load_oral_iron_effect_size(
13891389def load_ifa_excess_shift (
13901390 key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
13911391) -> pd .DataFrame :
1392- gestational_age_shift = load_ifa_weighted_avg_shift (key , location ).groupby (
1393- metadata .ARTIFACT_INDEX_COLUMNS + ["affected_entity" , "affected_measure" , "parameter" ]
1394- ).sum ()
1392+ gestational_age_shift = (
1393+ load_ifa_weighted_avg_shift (key , location )
1394+ .groupby (
1395+ metadata .ARTIFACT_INDEX_COLUMNS
1396+ + ["affected_entity" , "affected_measure" , "parameter" ]
1397+ )
1398+ .sum ()
1399+ )
13951400 birth_weight_shift = load_excess_shift (key , location )[gestational_age_shift .columns ]
13961401 all_ages_data = pd .concat ([birth_weight_shift , gestational_age_shift ])
13971402 return all_ages_data .query ("age_end <= 5.0" )
13981403
1404+
13991405def load_ifa_weighted_avg_shift (
14001406 key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
14011407) -> pd .DataFrame :
@@ -1404,6 +1410,7 @@ def load_ifa_weighted_avg_shift(
14041410 anc_proportion = get_data (data_keys .ANC .ANC1 , location )[shift_anc .columns ]
14051411 return shift_anc * anc_proportion + shift_non_anc * (1 - anc_proportion )
14061412
1413+
14071414def load_risk_specific_shift (
14081415 key : str , location : str , years : Optional [Union [int , str , List [int ]]] = None
14091416) -> pd .DataFrame :
@@ -1422,9 +1429,11 @@ def load_risk_specific_shift(
14221429 0.0 , columns = single_cat_shift .columns , index = single_cat_shift .index
14231430 )
14241431 else :
1425-
1432+
14261433 excess_shift = load_ifa_weighted_avg_shift (key , location )
1427- exposure = get_data (data_keys .IFA_SUPPLEMENTATION .COVERAGE , location )[excess_shift .columns ]
1434+ exposure = get_data (data_keys .IFA_SUPPLEMENTATION .COVERAGE , location )[
1435+ excess_shift .columns
1436+ ]
14281437 anc_proportion = get_data (data_keys .ANC .ANC1 , location )[excess_shift .columns ]
14291438
14301439 risk_specific_ga_shift = (
@@ -1434,10 +1443,14 @@ def load_risk_specific_shift(
14341443 )
14351444 .sum () # cat1 == 0
14361445 )
1437-
1438- birth_weight_shift = load_excess_shift (key , location )[excess_shift .columns ].groupby (
1439- metadata .ARTIFACT_INDEX_COLUMNS + ["affected_entity" , "affected_measure" ]
1440- ).sum () # cat1 == 0
1446+
1447+ birth_weight_shift = (
1448+ load_excess_shift (key , location )[excess_shift .columns ]
1449+ .groupby (
1450+ metadata .ARTIFACT_INDEX_COLUMNS + ["affected_entity" , "affected_measure" ]
1451+ )
1452+ .sum ()
1453+ ) # cat1 == 0
14411454 risk_specific_shift = pd .concat ([birth_weight_shift , risk_specific_ga_shift ])
14421455
14431456 return risk_specific_shift
@@ -1453,7 +1466,9 @@ def load_excess_shift(
14531466 ]["birth_weight.birth_exposure" ],
14541467 data_keys .IFA_SUPPLEMENTATION .RISK_SPECIFIC_SHIFT : data_values .ORAL_IRON_EFFECT_SIZES [
14551468 data_keys .IFA_SUPPLEMENTATION .EFFECT_SIZE
1456- ]["birth_weight.birth_exposure" ],
1469+ ][
1470+ "birth_weight.birth_exposure"
1471+ ],
14571472 data_keys .MMN_SUPPLEMENTATION .EXCESS_SHIFT : data_values .ORAL_IRON_EFFECT_SIZES [
14581473 data_keys .MMN_SUPPLEMENTATION .EFFECT_SIZE
14591474 ]["birth_weight.birth_exposure" ],
0 commit comments