Skip to main content

Tools to extract and work with UNESCO Institute of Statistics (UIS) data

Project description

unesco_reader

image image

unesco_reader is a python package to explore and extract data from UNESCO Institute of Statistics (UIS).

Motivation

Currently there is so API service to query UIS data (as of 23 June 2020). The only way to download UIS data is through the explorer or through their bulk download services, by downloading a zipped folder for each dataset locally. This package allows you to explore UIS datasets programmatically. The other motivation is to actively learn python development, packaging, and testing.

Installation

unesco_reader can be installed from PyPI: from the command line:

pip install unesco-reader

Usage

Basic Usage

Use with Python

To use, import the uis module from unesco_reader

from unesco_reader import uis

You can see available datasets or retrieve information for a particular dataset

To see all available datasets from UIS, run the following function:

print(uis.available_datasets()

>>> ['SDG', 'OPRI', 'SCI', 'SDG11', 'DEM']

Optionally you can return available datasets as names, and see available datasets that belong to a particular category.

print(uis.available_datasets(as_names=True, category='education'))

>>> ['SDG Global and Thematic Indicators' 'Other Policy Relevant Indicators']

To see details about a particular dataset, call the dataset_info() function passing in either the dataset code or name.

uis.dataset_info('SDG')

>>> ----------------  ----------------------------------------------------------------------------------------
    dataset_name      SDG Global and Thematic Indicators
    dataset_code      SDG
    dataset_category  education
    regional          True
    link              https://apimgmtstzgjpfeq2u763lag.blob.core.windows.net/content/MediaLibrary/bdds/SDG.zip
    ----------------  ----------------------------------------------------------------------------------------

To exctract and explore the data in a particular dataset, use the UIS class. A UIS object allows a user to

  • extract the data, either from directly from UIS bulk download services, or from a zipped file downloaded locally
  • explore the data easily and retrieve relevant information about the data

To use, create an instance of UIS, passing either the dataset code or name. Here we create an object for the "SDG" dataset.

from unesco_reader.uis import UIS
sdg = UIS("SDG")

Once instantiated, you can retrieve relevant information about the dataset

sdg = UIS("SDG")
print(sdg.name)

>>> 'SDG Global and Thematic Indicators'

To load the data to the object, use the load_data method. If you already downloaded the zipped file from UIS, you can pass a path to the file, and the data will be read from this local path. Otherwise, the data will be exctracted directly from the web.

sdg = UIS("SDG")
sdg.load_data()

To retrieve the data as a dataframe, use the get_data method.

sdg = UIS("SDG")
sdg.load_data()
df = sdg.get_data()
print(df)

The above code would result in a dataframe similar to this:

INDICATOR_ID INDICATOR_NAME COUNTRY_ID COUNTRY_NAME YEAR VALUE
ADMI.ENDOFLOWERSEC.MAT Administration of a nationally-representative... ABW Aruba 2014 0.0
ADMI.ENDOFLOWERSEC.MAT Administration of a nationally-representative... ABW Aruba 2015 0.0
ADMI.ENDOFLOWERSEC.MAT Administration of a nationally-representative... ABW Aruba 2016 0.0
ADMI.ENDOFLOWERSEC.MAT Administration of a nationally-representative... ABW Aruba 2017 0.0
ADMI.ENDOFLOWERSEC.MAT Administration of a nationally-representative... ABW Aruba 2018 0.0

You can pass in additional parameters specifying to return regional data (if available in the dataset) and to include metadata in the dataframe

sdg.get_data(grouping="regional", include_metadata=True)

To see additional information about the dataset use the info method

sdg.info()

>>> --------------------  ----------------------------------------------------------------------------------------
    code                  SDG
    name                  SDG Global and Thematic Indicators
    url                   https://apimgmtstzgjpfeq2u763lag.blob.core.windows.net/content/MediaLibrary/bdds/SDG.zip
    category              education
    available indicators  1609
    available countries   241
    time range            1950 - 2022
    available regions     179
    --------------------  ----------------------------------------------------------------------------------------

Several other tools to explore the data exist (full documentation coming soon) and additional tools will be added as this package is in active development Any suggestions for new features or improvements are welcome!

Credits

This package was created with Cookiecutter and the giswqs/pypackage project template.

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

unesco_reader-0.1.2.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

unesco_reader-0.1.2-py2.py3-none-any.whl (10.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file unesco_reader-0.1.2.tar.gz.

File metadata

  • Download URL: unesco_reader-0.1.2.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for unesco_reader-0.1.2.tar.gz
Algorithm Hash digest
SHA256 41622229719ff2064caef58bc9be4901fc19da8786068077ce3fd1f4898e07ff
MD5 77b0385d3091476b76bbe808d9641b1c
BLAKE2b-256 ad95cd5a3fec330c942044ecf8d065535f322db59d0df59e9042eb71b9d93686

See more details on using hashes here.

File details

Details for the file unesco_reader-0.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: unesco_reader-0.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for unesco_reader-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 38a9479cd5a07408526e1a88e8c6bfad6f4ab8d98892f3bfcbe21b453a25f808
MD5 915e952245c9739cabca64176090b9ac
BLAKE2b-256 485660875fa8a055ba5b581c190d11fa0565c3eeb4d475bea952d8259be6ee76

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