def group_stat_vars_by_observation_properties(indicator_codes):
    ' Groups stat vars by their observation schemas.\n\n        Groups Stat Vars by their inclusion of StatVar Observation\n        properties like measurementMethod or Unit.\n        The current template MCF schema does not support optional values in the\n        CSV so we must place these stat vars into\n        different template MCFs and CSVs.\n\n        Args:\n            indicator_codes: List of World Bank indicator codes with\n                their Data Commons mappings, as a pandas dataframe.\n\n        Returns:\n            Array of tuples for each statistical variable grouping.\n                1) template MCF, as a string.\n                2) columns to include in exported csv, as a list of strings.\n                3) indicator codes in this grouping, as a list of strings.\n    '
    properties_of_stat_var_observation = ['measurementMethod', 'scalingFactor', 'sourceScalingFactor', 'unit']
    tmcfs_for_stat_vars = []
    null_status = indicator_codes.notna()
    for permutation in list(itertools.product([False, True], repeat=len(properties_of_stat_var_observation))):
        codes_that_match = null_status.copy()
        base_template_mcf = TEMPLATE_TMCF
        cols_to_include_in_csv = ['IndicatorCode']
        for (include_col, column) in zip(permutation, properties_of_stat_var_observation):
            codes_that_match = codes_that_match.query(f'{column} == {include_col}')
            if include_col:
                base_template_mcf += f'''{column}: C:WorldBank->{column}
'''
                cols_to_include_in_csv.append(f'{column}')
        tmcfs_for_stat_vars.append((base_template_mcf, cols_to_include_in_csv, list(indicator_codes.loc[codes_that_match.index]['IndicatorCode'])))
    return tmcfs_for_stat_vars
Groups stat vars by their observation schemas.

Groups Stat Vars by their inclusion of StatVar Observation
properties like measurementMethod or Unit.
The current template MCF schema does not support optional values in the
CSV so we must place these stat vars into
different template MCFs and CSVs.

Args:
    indicator_codes: List of World Bank indicator codes with
        their Data Commons mappings, as a pandas dataframe.

Returns:
    Array of tuples for each statistical variable grouping.
        1) template MCF, as a string.
        2) columns to include in exported csv, as a list of strings.
        3) indicator codes in this grouping, as a list of strings.
def group_stat_vars_by_observation_properties(indicator_codes):
    ' Groups stat vars by their observation schemas.\n\n        Groups Stat Vars by their inclusion of StatVar Observation\n        properties like measurementMethod or Unit.\n        The current template MCF schema does not support optional values in the\n        CSV so we must place these stat vars into\n        different template MCFs and CSVs.\n\n        Args:\n            indicator_codes: List of World Bank indicator codes with\n                their Data Commons mappings, as a pandas dataframe.\n\n        Returns:\n            Array of tuples for each statistical variable grouping.\n                1) template MCF, as a string.\n                2) columns to include in exported csv, as a list of strings.\n                3) indicator codes in this grouping, as a list of strings.\n    '
    properties_of_stat_var_observation = ['measurementMethod', 'scalingFactor', 'sourceScalingFactor', 'unit']
    tmcfs_for_stat_vars = []
    null_status = indicator_codes.notna()
    for permutation in list(itertools.product([False, True], repeat=len(properties_of_stat_var_observation))):
        codes_that_match = null_status.copy()
        base_template_mcf = TEMPLATE_TMCF
        cols_to_include_in_csv = ['IndicatorCode']
        for (include_col, column) in zip(permutation, properties_of_stat_var_observation):
            codes_that_match = codes_that_match.query(f'{column} == {include_col}')
            if include_col:
                base_template_mcf += f'{column}: C:WorldBank->{column}
'
                cols_to_include_in_csv.append(f'{column}')
        tmcfs_for_stat_vars.append((base_template_mcf, cols_to_include_in_csv, list(indicator_codes.loc[codes_that_match.index]['IndicatorCode'])))
    return tmcfs_for_stat_vars