def get_pooled_global_allocation_for_year(self, year): if year not in self.year_cache: global_funding_by_donor =\ fts_queries.fetch_grouping_type_json_for_year_as_dataframe('funding', year, 'donor', 'organization') pooled_funds_amounts = global_funding_by_donor.funding.loc[POOLED_FUNDS] self.year_cache[year] = pooled_funds_amounts return self.year_cache[year]
def get_total_country_funding_for_year(self, country_code, year): if year not in self.year_cache: funding_by_country =\ fts_queries.fetch_grouping_type_json_for_year_as_dataframe('funding', year, 'country', 'country') self.year_cache[year] = funding_by_country # possibly no funding at all in that year funding_series = self.year_cache[year] if funding_series.empty: return 0 country_name = self.country_iso_code_to_name[country_code] if country_name in funding_series.funding: return funding_series.funding.loc[country_name] else: return 0