Skip to main content

Deflate Nominal Brazilian Reais

Project description

deflateBR

PyPi version Build Status Azure Build Status Travis Coverage Status

PyPi downloads

deflateBR is a Python package used to deflate nominal Brazilian Reais using several popular price indexes. It is a reimplementation of the great deflateBR R package by Fernando Meireles.

Installation

pip install deflateBR

Examples

The deflateBR’s main function, deflate, requires three arguments to work: an int of float vector of nominal Reais (nominal_values); a str or datetime vector of corresponding dates (nominal_dates); and a reference month in the YYYY-MM format (real_date), used to deflate the values. An example:

To deflate BRL R$100,00 (one hundred brazilian reais) in January 2015, simply do

import deflatebr as dbr

dbr.deflate(nominal_values=100, nominal_dates='2015-01-01', 
            real_date='2020-01')
array([131.32029183])

To deflate a bigger series, do

import pandas as pd

df = pd.DataFrame({'nom_values':[100,200,300,400],
                    'dates':['2015-01-01', '2015-02-01',
                            '2015-10-01', '2015-12-01']})
df
   nom_values       dates
0         100  2015-01-01
1         200  2015-02-01
2         300  2015-10-01
3         400  2015-12-01
dbr.deflate(nominal_values=df.nom_values, nominal_dates=df.dates, 
            real_date='2020-01')
array([131.32029183, 259.42387232, 365.99132289, 479.18030761])

To display a progress bar, set progress_bar=True. If you are running on a jupyter notebook or a jupyter lab, set also on_jupyter=True to have a nice HTML progress bar:

dbr.deflate(nominal_values=df.nom_values, nominal_dates=df.dates, 
            real_date='2020-01', progress_bar=True, on_jupyter=False)
100%|██████████████████████████████| 6/6 [00:00<00:00, 3006.67it/s] 
array([1084.40219182, 1192.842411  , 1247.06252059, 1053.40923236,
   1264.09107883, 1316.76154045])

Behind the scenes, deflateBR requests data from IPEADATA’s API on one these five Brazilian price indexes: IPCA and INPC, maintained by IBGE; and IGP-M, IGP-DI, and IPC maintained by FGV/IBRE. To select one of the available price indexes, just provide one of the following options to the index = argument: ipca, igpm, igpdi, ipc, and inpc. In the following, the INPC index is used.

dbr.deflate(nominal_values=100, nominal_dates='2015-01-01', 
            real_date='2020-01', index='inpc')
array([131.06584509])

Methodology

Following standard practice, seconded by the Brazilian Central Bank, the deflateBR adjusts for inflation by multiplying nominal Reais by the ratio between the original and the reference price indexes. For example, to adjust 100 reais of January 2018, with IPCA index of 4916.46, to August 2018, with IPCA of 5056.56 in the previous month, we first calculate the ratio between the two indexes (e.g., 5056.56 / 4916.46 = 1.028496) and then multiply this value by 100 (e.g., 102.84 adjusted Reais). The deflate function gives exactly the same result:

dbr.deflate(100,"2018-01-01", "2018-08", "ipca")
array([102.84961131])

Authors

Neylson Crepalde & Fernando Meireles

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

deflateBR-0.2.1.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

deflateBR-0.2.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file deflateBR-0.2.1.tar.gz.

File metadata

  • Download URL: deflateBR-0.2.1.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for deflateBR-0.2.1.tar.gz
Algorithm Hash digest
SHA256 107502defd3c613155995935d57755a40dc969396c46a764940d0fb66cf63d4c
MD5 4e83c49259731de26719e62a372ef0b6
BLAKE2b-256 bac642a345e67daaaa81ff185f8f743a037120343d35b7703662c3d89d3b0cde

See more details on using hashes here.

File details

Details for the file deflateBR-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: deflateBR-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for deflateBR-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2644c19041c3684bb3b4f47062389daeb21b53bc74c26352ac5f94587c55b5e5
MD5 1c87d6196ddae2f0e942cb441815ec9a
BLAKE2b-256 8d01c6b3218e23d95430c0c9638f59057887d24dd22c766c35a713f493137b6f

See more details on using hashes here.

Supported by

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