Skip to main content

Overview

This project simplifies gathering and processing of Uruguayan economic statistics. Data is retrieved from (mostly) government sources, processed into a familiar tabular format, tagged with useful metadata and can be transformed in several ways (converting to dollars, calculating rolling averages, resampling to other frequencies, etc.).

If this screenshot gives you anxiety, this package should be of interest.

A webapp with a limited but interactive version of econuy is available at econ.uy. Check out the repo as well.

The most basic econuy workflow goes like this:

from econuy import load_dataset, load_datasets_parallel

data1 = load_dataset("cpi")

Installation

  • PyPI:
pip install econuy
  • Git:
git clone https://github.com/rxavier/econuy.git
cd econuy
python setup.py install

Usage

Full API documentation available at RTD

Cache directory

econuy saves and reads data to a directory which by default is at the system home / .cache / econuy. This can be modified for all data loading by setting ECONUY_DATA_DIR or directly in load_dataset(data_dir=...).

Dataset load branching

  1. Check that the dataset exists in the REGISTRY.
  2. Cache check:
  • If skip_cache=True, download dataset
  • If skip_cache=False (default):
    • Check whether the dataset exists in the cache.
      • If it exists:
        • Recency check:
          • If it was created in the last day, return existing dataset.
          • If it was created prior to the last day and skip_update=False, download dataset.
          • If it was created prior to the last day and skip_update=True, return existing dataset.
      • If it does not exist, download dataset
  1. If the dataset was downloaded, try to update the cache:
  • Validation:
    • If force_overwrite=True, overwrite dataset.
    • If force_overwrite=False (default):
      • If the new dataset is similar to the cached dataset, overwrite dataset.
      • If the new dataset is not similar to the cached dataset, do not overwrite dataset.

Loading and transforming data

from econuy import load_dataset, load_datasets_parallel


# load a single dataset
data1 = load_dataset("cpi")

# load a single dataset and chain transformations
data2 = (
    load_dataset("fiscal_balance_nonfinancial_public_sector")
    .select(names="Ingresos: SPNF")
    .resample("QE-DEC", "sum")
    .decompose(method="x13", component="t-c")
    .filter(start_date="2014-01-01")
    )

This returns a Dataset object, which contains a Metadata object.

You can also load multiple datasets fast:

# load multiple datasets using threads or processes
data3 = load_datasets_parallel(["nxr_monthly", "ppi"])

Finding datasets

from econuy.utils.operations import REGISTRY


REGISTRY.list_available()
REGISTRY.list_by_area("activity")

Dataset metadata

Datasets include the following metadata per indicator:

  1. Indicator name
  2. Area
  3. Frequency
  4. Currency
  5. Inflation adjustment
  6. Unit
  7. Seasonal adjustment
  8. Type (stock or flow)
  9. Cumulative periods

Transformation methods

Dataset objects have multiple methods to transform their underlying data and update their metadata.

  • resample() - resample data to a different frequency, taking into account whether data is of stock or flow type.
  • chg_diff() - calculate percent changes or differences for same period last year, last period or at annual rate.
  • decompose() - seasonally decompose series into trend or seasonally adjusted components.
  • convert() - convert to US dollars, constant prices or percent of GDP.
  • rebase() - set a period or window as 100, scale rest accordingly
  • rolling() - calculate rolling windows, either average or sum.

External binaries and libraries

unrar libraries

The patool package is used in order to access data provided in .rar format. This package requires that you have the unrar binaries in your system, which in most cases you should already have. You can can get them from here if you don't.


Caveats

This project is heavily based on getting data from online sources that could change without notice, causing methods that download data to fail. While I try to stay on my toes and fix these quickly, it helps if you create an issue when you find one of these (or even submit a fix!).

Release files for econuy 0.23.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for econuy 0.23.0
File Size Uploaded
econuy-0.23.0.tar.gz 104.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for econuy 0.23.0
File Interpreter ABI Platform
econuy-0.23.0-py3-none-any.whl Python 3 none any Details

Total release size: 216.7 kB

Release files / econuy-0.23.0.tar.gz

Download URL econuy-0.23.0.tar.gz
Size 104.7 kB
Tags Source
SHA-256 checksum
How to use checksums
75effb8b38d40c2a679a71ca6b36f601fbd2fd8f5e2600b1f0fd498b9b06870b
BLAKE2b-256 checksum
How to use checksums
63dda432d8e239d69c27d43f7b774d12ffadb01fb6a11410b822f0685812e771
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 1, 2025.

Transparency log

Release files / econuy-0.23.0-py3-none-any.whl

Download URL econuy-0.23.0-py3-none-any.whl
Size 112.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79833c0676f5424866402be26c2b4d470f5a47130900d977948e784dbab1fe55
BLAKE2b-256 checksum
How to use checksums
fb3e4a74fd13e8c55d21322221a74ed5bf0e4ddd5125f2ffea45074b26b50a40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 1, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.23.0 This release

2 release files

0.21.8

2 release files

0.21.6

2 release files

0.20.3

2 release files

0.20.2

2 release files

0.20.1

2 release files

0.20.0

2 release files

0.18.6

2 release files

0.18.5

2 release files

0.18.3

2 release files

0.18.2

2 release files

0.18.1

2 release files

0.18.0

2 release files

0.17.2

2 release files

0.17.1

2 release files

0.17.0

2 release files

0.16.7

2 release files

0.16.6

2 release files

0.16.5

2 release files

0.16.4

2 release files

0.16.3

2 release files

0.15.0

2 release files

0.14.7

2 release files

0.14.6

2 release files

0.14.5

2 release files

0.14.4

2 release files

0.14.2

2 release files

0.14.1

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.12.2

2 release files

0.12.1

2 release files

0.10.4

2 release files

0.10.3

2 release files

0.10.2

2 release files

0.10.0

2 release files

0.9.7

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page