bblocks.import_tools.ilo ======================== .. py:module:: bblocks.import_tools.ilo .. autoapi-nested-parse:: Extract ILO data Attributes ---------- .. autoapisummary:: bblocks.import_tools.ilo.BASE_URL Classes ------- .. autoapisummary:: bblocks.import_tools.ilo.ILO Functions --------- .. autoapisummary:: bblocks.import_tools.ilo._get_glossaries_links bblocks.import_tools.ilo.get_glossaries bblocks.import_tools.ilo.get_area_dict bblocks.import_tools.ilo.extract_data bblocks.import_tools.ilo.clean_df bblocks.import_tools.ilo.download_data Module Contents --------------- .. py:data:: BASE_URL :value: 'https://www.ilo.org' .. py:function:: _get_glossaries_links() -> dict[str, str] Get reference dictionaries for codes and names of indicators .. py:function:: 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 :rtype: dict .. py:function:: 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 :rtype: dict .. py:function:: extract_data(indicator_code: str) -> pandas.DataFrame Extract data from ILO website :param indicator_code: Indicator code to extract :type indicator_code: str :returns: Dataframe with the data :rtype: pd.DataFrame .. py:function:: clean_df(df: pandas.DataFrame, glossaries: dict[str:dict], areas: dict[str:str]) -> pandas.DataFrame Clean a dataframe :param df: Dataframe to clean :type df: pd.DataFrame :param glossaries: Dictionary with the names as keys and a dictionary of codes and names as values :type glossaries: dict :param areas: Dictionary with area codes as keys and names as values :returns: Cleaned dataframe :rtype: pd.DataFrame .. py:function:: download_data(indicator: str, path: str, glossaries: dict, areas: dict) -> None Pipeline to download an indicator and save it to disk. :param indicator: Indicator code to download :param path: Path to save the data to :param glossaries: dictionary to map codes to names :param areas: dictionary to map area codes to names .. py:class:: ILO Bases: :py:obj:`bblocks.import_tools.common.ImportData` An 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. .. py:attribute:: _glossaries :type: dict :value: None .. py:attribute:: _available_indicators :type: pandas.DataFrame :value: None .. py:attribute:: _area_dict :type: dict :value: None .. py:method:: 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. .. py:method:: _load_glossaries() -> None Load the glossaries to the object .. py:method:: _load_area_dict() -> None Load the area dictionary to the object .. py:method:: 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. :param indicator: Indicator code or list of indicator codes to load :type indicator: str | list :returns: The object with the data loaded :rtype: ImportData .. py:method:: 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. :param reload_data: If True, it will reload the data to the object. Defaults to True. :returns: The object with the updated data :rtype: ImportData