Skip to main content

Deflate Nominal Brazilian Reais

Project description

deflateBR

PyPi version Build Status Build Status 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])

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.tar.gz (8.8 kB view hashes)

Uploaded Source

Built Distribution

deflateBR-0.2-py3-none-any.whl (5.9 kB view hashes)

Uploaded Python 3

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