def output_csv_and_tmcf_by_grouping(worldbank_dataframe, tmcfs_for_stat_vars, indicator_codes):
    ' Outputs TMCFs and CSVs for each grouping of stat vars.\n\n        Args:\n            worldbank_dataframe: Dataframe containing all indicators for all\n                countries.\n            tmcfs_for_stat_vars: Array of tuples of template MCF,\n                columns on stat var observations,\n                indicator codes for that template.\n            indicator_codes -> Dataframe with INDICATOR_CODES to include.\n    '
    output_csv = worldbank_dataframe[['StatisticalVariable', 'IndicatorCode', 'ISO3166Alpha3', 'Year', 'Value']]
    for (index, enum) in enumerate(tmcfs_for_stat_vars):
        (tmcf, stat_var_obs_cols, stat_vars_in_group) = enum
        if (len(stat_vars_in_group) != 0):
            with open(f'output/WorldBank_{index}.tmcf', 'w', newline='') as f_out:
                f_out.write(tmcf)
            matching_csv = output_csv[output_csv['IndicatorCode'].isin(stat_vars_in_group)]
            if (len(stat_var_obs_cols) > 1):
                matching_csv = pd.merge(matching_csv, indicator_codes[stat_var_obs_cols], on='IndicatorCode')
            matching_csv = matching_csv.round(10)
            matching_csv.drop('IndicatorCode', axis=1).to_csv(f'output/WorldBank_{index}.csv', float_format='%.10f', index=False)
Outputs TMCFs and CSVs for each grouping of stat vars.

Args:
    worldbank_dataframe: Dataframe containing all indicators for all
        countries.
    tmcfs_for_stat_vars: Array of tuples of template MCF,
        columns on stat var observations,
        indicator codes for that template.
    indicator_codes -> Dataframe with INDICATOR_CODES to include.
def output_csv_and_tmcf_by_grouping(worldbank_dataframe, tmcfs_for_stat_vars, indicator_codes):
    ' Outputs TMCFs and CSVs for each grouping of stat vars.\n\n        Args:\n            worldbank_dataframe: Dataframe containing all indicators for all\n                countries.\n            tmcfs_for_stat_vars: Array of tuples of template MCF,\n                columns on stat var observations,\n                indicator codes for that template.\n            indicator_codes -> Dataframe with INDICATOR_CODES to include.\n    '
    output_csv = worldbank_dataframe[['StatisticalVariable', 'IndicatorCode', 'ISO3166Alpha3', 'Year', 'Value']]
    for (index, enum) in enumerate(tmcfs_for_stat_vars):
        (tmcf, stat_var_obs_cols, stat_vars_in_group) = enum
        if (len(stat_vars_in_group) != 0):
            with open(f'output/WorldBank_{index}.tmcf', 'w', newline=) as f_out:
                f_out.write(tmcf)
            matching_csv = output_csv[output_csv['IndicatorCode'].isin(stat_vars_in_group)]
            if (len(stat_var_obs_cols) > 1):
                matching_csv = pd.merge(matching_csv, indicator_codes[stat_var_obs_cols], on='IndicatorCode')
            matching_csv = matching_csv.round(10)
            matching_csv.drop('IndicatorCode', axis=1).to_csv(f'output/WorldBank_{index}.csv', float_format='%.10f', index=False)