imf_reader.weo.reader ===================== .. py:module:: imf_reader.weo.reader .. autoapi-nested-parse:: Main interface to the WEO database. Functions --------- .. autoapisummary:: imf_reader.weo.reader.validate_version imf_reader.weo.reader.gen_latest_version imf_reader.weo.reader.roll_back_version imf_reader.weo.reader._fetch imf_reader.weo.reader.fetch_data Module Contents --------------- .. py:function:: validate_version(version: tuple) -> imf_reader.weo.Version Validate the version Make sure that it is a tuple of month and year and the month is either April or October. :param version: The version to validate :returns: A tuple of the month and year .. py:function:: gen_latest_version() -> imf_reader.weo.Version Generates the latest expected version based on the current date as a tuple of month and year :returns: A tuple of the latest month and year .. py:function:: roll_back_version(version: imf_reader.weo.Version) -> imf_reader.weo.Version Roll back version to the previous version This function rolls back the version passed to the expected previous version. If the version is April 2024 it will roll back to October 2023. If the version is October 2023 it will roll back to April 2023. :param version: The version to roll back :returns: The rolled back version .. py:function:: _fetch(version: imf_reader.weo.Version) -> pandas.DataFrame Helper function which handles caching and fetching the data from the IMF website :param version: The version of the WEO data to fetch :returns: A pandas DataFrame containing the WEO data .. py:function:: fetch_data(version: imf_reader.weo.Version | None = None) -> pandas.DataFrame Fetch WEO data By default, this function fetched data for the latest WEO publication. If a specific publication version is required, the version can be passed as a tuple of month and year. WEO data is released in April and October each year. For the version month, the month must be either "April" or "October" This function caches the data for faster access and to prevent multiple requests to the IMF website. To clear the cache, use the `clear_cache` function. e.g. >>> fetch_data() # fetches the latest data >>> fetch_data(("April", 2024)) # fetches the data for April 2024 :param version: The version of the WEO data to fetch as a tuple eg `("April", 2023). By default, the latest version is fetched. :returns: A pandas DataFrame containing the WEO data