def build_stat_vars_from_indicator_list(row):
    ' Generates World Bank StatVar for a row in the indicators dataframe. '

    def row_to_constraints(row):
        ' Helper to generate list of constraints. '
        constraints_text = ''
        next_constraint = 1
        while ((f'p{next_constraint}' in row) and (not pd.isna(row[f'p{next_constraint}']))):
            variable = row[f'p{next_constraint}']
            constraint = row[f'v{next_constraint}']
            constraints_text += f'''{variable}: dcs:{constraint}
'''
            next_constraint += 1
        return constraints_text
    new_stat_var = TEMPLATE_STAT_VAR.replace('{INDICATOR}', row['IndicatorCode'].replace('.', '_')).replace('{NAME}', row['IndicatorName']).replace('{DESCRIPTION}', row['SourceNote']).replace('{measuredProperty}', row['measuredProp']).replace('{CONSTRAINTS}', row_to_constraints(row))
    for optional_col in ['populationType', 'statType', 'measurementDenominator']:
        if (not pd.isna(row[optional_col])):
            new_stat_var = new_stat_var.replace(f'{{{optional_col}}}', row[optional_col])
        else:
            new_stat_var = new_stat_var.replace(f'''{optional_col}: dcs:{{{optional_col}}}
''', '')
    return new_stat_var
Generates World Bank StatVar for a row in the indicators dataframe.
def build_stat_vars_from_indicator_list(row):
    '  '

    def row_to_constraints(row):
        ' Helper to generate list of constraints. '
        constraints_text = 
        next_constraint = 1
        while ((f'p{next_constraint}' in row) and (not pd.isna(row[f'p{next_constraint}']))):
            variable = row[f'p{next_constraint}']
            constraint = row[f'v{next_constraint}']
            constraints_text += f'{variable}: dcs:{constraint}
'
            next_constraint += 1
        return constraints_text
    new_stat_var = TEMPLATE_STAT_VAR.replace('{INDICATOR}', row['IndicatorCode'].replace('.', '_')).replace('{NAME}', row['IndicatorName']).replace('{DESCRIPTION}', row['SourceNote']).replace('{measuredProperty}', row['measuredProp']).replace('{CONSTRAINTS}', row_to_constraints(row))
    for optional_col in ['populationType', 'statType', 'measurementDenominator']:
        if (not pd.isna(row[optional_col])):
            new_stat_var = new_stat_var.replace(f'{{{optional_col}}}', row[optional_col])
        else:
            new_stat_var = new_stat_var.replace(f'{optional_col}: dcs:{{{optional_col}}}
', )
    return new_stat_var