Skip to content

Commit

Permalink
Add regions abbreviations to data_fr
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAndorra committed Nov 7, 2020
1 parent 4ce4c62 commit e4baaec
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions rtlive/sources/data_fr.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
_log = logging.getLogger(__file__)


def get_regions_metadata() -> Tuple[Dict[str, str], Dict[str, float]]:
def get_regions_metadata() -> Tuple[Dict[str, str], Dict[str, str], Dict[str, float]]:
"""
Link to regions' population: https://www.insee.fr/fr/statistiques/1893198
Link to regions' codes: https://www.insee.fr/fr/information/2114819#titre-bloc-29
Link to regions' abbreviations: https://fr.wikipedia.org/wiki/R%C3%A9gion_fran%C3%A7aise
Returns
-------
Tuple of dictionaries: one mapping regions' codes to regions' names, the other mapping regions'
codes to regions' population.
Tuple of dictionaries: one mapping regions' codes to regions' names, another mapping regions'
codes to regions' population, and a final one mapping regions' codes to regions' abbreviations.
"""
REGIONS_RAW_DATA = {
"Name": [
Expand All @@ -44,6 +45,26 @@ def get_regions_metadata() -> Tuple[Dict[str, str], Dict[str, float]]:
"La Réunion",
"Mayotte",
],
"Abbreviation": [
"ARA",
"BFC",
"BRE",
"CVL",
"COR",
"GES",
"HDF",
"IDF",
"NOR",
"NAQ",
"OCC",
"PDL",
"PAC",
"GP",
"MQ",
"GF",
"RE",
"YT",
],
"Code": [
"84",
"27",
Expand Down Expand Up @@ -95,8 +116,13 @@ def get_regions_metadata() -> Tuple[Dict[str, str], Dict[str, float]]:

reg_pop_codes.loc["all", "Population"] = reg_pop_codes.Population.sum()
reg_pop_codes.loc["all", "Name"] = "France"
reg_pop_codes.loc["all", "Abbreviation"] = "FR"

return reg_pop_codes.to_dict()["Name"], reg_pop_codes.to_dict()["Population"]
return (
reg_pop_codes.to_dict()["Name"],
reg_pop_codes.to_dict()["Abbreviation"],
reg_pop_codes.to_dict()["Population"],
)


def get_data_FR(run_date: pandas.Timestamp) -> pandas.DataFrame:
Expand Down Expand Up @@ -239,11 +265,12 @@ def forecast_FR(df: pandas.DataFrame) -> Tuple[pandas.DataFrame, dict]:
return pandas.concat(df_list), results


regions_names, regions_population = get_regions_metadata()
regions_names, regions_abbs, regions_population = get_regions_metadata()
data.set_country_support(
country_alpha2="FR",
compute_zone=data.Zone.Europe,
region_name=regions_names,
region_short_name=regions_abbs,
region_population=regions_population,
fn_load=get_data_FR,
fn_process=forecast_FR,
Expand Down

0 comments on commit e4baaec

Please sign in to comment.