Skip to main content

Python client to read IMF WEO dataset as pandas dataframe

Project description

weo-reader

  1. The program uses Python 3.6. To install weo as a python package use:

pip install weo

  1. You need the data saved as a local file. Download latest WEO country data file from IMF web site (for example as weo.csv).

You can do it manually in a command line with curl command:


curl -o weo.csv https://www.imf.org/external/pubs/ft/weo/2019/02/weodata/WEOOct2019all.xls

Please note WEOOct2019all.xls is in fact a tab-delimited CSV file.

Alternatively, can use weo.download() function:

from weo import download



download('weo.csv', 2019, 2)
  1. Use WEO class from weo package or weo.py to view and extract data. WEO is a wrapper around a by-country pandas dataframe that ensures proper data import and easier access to it.

  2. Things to try in a REPL, by line:

from weo import WEO



w = WEO('weo.csv') 



# What is inside?

w.variables()

w.units()    

w.units('Gross domestic product, current prices')

w.codes()

w.code('LUR')



# Countries

w.find_countries('United')

w.iso_code('Netherlands')



# Get some data

w.get('General government gross debt', 'Percent of GDP')

w.gdp_usd(2024).head(20).sort_values().plot.barh(title="GDP by country, USD bln (2024)")

w.country('DEU', 2018)
  1. Try Google Colab Notebook

Dev notes

  • WEOOct2019all.xls file from the web site is really a CSV file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

weo-0.0.8.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

weo-0.0.8-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file weo-0.0.8.tar.gz.

File metadata

  • Download URL: weo-0.0.8.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for weo-0.0.8.tar.gz
Algorithm Hash digest
SHA256 cae0ebf64e1d028e31696d74663fc00548c233a2b86ffc36a4eb68fa6af396fe
MD5 5ce5a466e27606b320d21d5fb0c2e0a3
BLAKE2b-256 83bfc5c0049f5c313cc184ad85879863303b7bd388417a27dc6ba91ddd8c8c33

See more details on using hashes here.

File details

Details for the file weo-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: weo-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for weo-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 327df2b90093c192f5c8731841e453b7131391b120116a84b7d150168607146d
MD5 e89a137e21d9fedf8de61423a8a95442
BLAKE2b-256 c0e41f6bf8a10effb14235a2caf03848af5ba05b9c41213a0c04a99ee2a08990

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page