deflateBR

Deflate Nominal Brazilian Reais


Keywords
deflate, deflation, economics, salary, wage, finance
License
MIT
Install
pip install deflateBR==0.2.1

Documentation

deflateBR

forthebadge made-with-python

PyPI version fury.io Build Status Azure Build Status Travis Coverage Status Codacy Badge MIT license PyPI pyversions PyPI status PyPi downloads GitHub issues GitHub issues-closed

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