bblocks.import_tools.ilo
Extract ILO data
Attributes
Classes
An object to import data from the ILO website |
Functions
|
Get reference dictionaries for codes and names of indicators |
|
Get reference dictionaries for codes and names of indicators |
|
Get dictionary to map area codes to names |
|
Extract data from ILO website |
|
Clean a dataframe |
|
Pipeline to download an indicator and save it to disk. |
Module Contents
- bblocks.import_tools.ilo.BASE_URL = 'https://www.ilo.org'
- bblocks.import_tools.ilo._get_glossaries_links() dict[str, str]
Get reference dictionaries for codes and names of indicators
- bblocks.import_tools.ilo.get_glossaries() dict[str, dict[str, str]]
Get reference dictionaries for codes and names of indicators
- Returns:
Dictionary with the names as keys and a dictionary of codes and names as values
- Return type:
dict
- bblocks.import_tools.ilo.get_area_dict() dict[str, str]
Get dictionary to map area codes to names
- Returns:
Dictionary with area codes as keys and names as values
- Return type:
dict
- bblocks.import_tools.ilo.extract_data(indicator_code: str) pandas.DataFrame
Extract data from ILO website
- Parameters:
indicator_code (str) – Indicator code to extract
- Returns:
Dataframe with the data
- Return type:
pd.DataFrame
- bblocks.import_tools.ilo.clean_df(df: pandas.DataFrame, glossaries: dict[str:dict], areas: dict[str:str]) pandas.DataFrame
Clean a dataframe
- Parameters:
df (pd.DataFrame) – Dataframe to clean
glossaries (dict) – Dictionary with the names as keys and a dictionary of codes and names as values
areas – Dictionary with area codes as keys and names as values
- Returns:
Cleaned dataframe
- Return type:
pd.DataFrame
- bblocks.import_tools.ilo.download_data(indicator: str, path: str, glossaries: dict, areas: dict) None
Pipeline to download an indicator and save it to disk.
- Parameters:
indicator – Indicator code to download
path – Path to save the data to
glossaries – dictionary to map codes to names
areas – dictionary to map area codes to names
- class bblocks.import_tools.ilo.ILO
Bases:
bblocks.import_tools.common.ImportDataAn object to import data from the ILO website
To use this object, first create an instance of it and then call the load_data method to load an indicator to the object. Use the get_data method to get the data from the object. To update the data saved on disk and in the object, call the update_data method. The method available_indicators() returns a dataframe with information on all the available indicators from the ILO.
- _glossaries: dict = None
- _available_indicators: pandas.DataFrame = None
- _area_dict: dict = None
- available_indicators() pandas.DataFrame
Return a dataframe with information on all the available indicators from the ILO
If the dataframe is not already loaded to the object, it will be downloaded from the ILO website.
- _load_glossaries() None
Load the glossaries to the object
- _load_area_dict() None
Load the area dictionary to the object
- load_data(indicator: str | list) bblocks.import_tools.common.ImportData
Load an ILO indicator to the object
This method with check if the indicator is already saved to disk. If not, it will downlaod it to disk and load it to the object. Use the get_data method to get the data from the object after it is loaded.
- Parameters:
indicator (str | list) – Indicator code or list of indicator codes to load
- Returns:
The object with the data loaded
- Return type:
- update_data(reload_data: bool = True) bblocks.import_tools.common.ImportData
Update the data saved on disk
When called it will go through all the indicators loaded to the object and download the data again. If reload_data is True, it will also reload the data to the object.
- Parameters:
reload_data – If True, it will reload the data to the object. Defaults to True.
- Returns:
The object with the updated data
- Return type: