Skip to main content

Deflate Nominal Brazilian Reais

Project description


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.


pip install deflateBR


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', 

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']})
   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, 
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')


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")


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.

Files for deflateBR, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size deflateBR-0.2.1-py3-none-any.whl (6.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size deflateBR-0.2.1.tar.gz (9.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page