Real vs. Nominal: A Tutorial on Deflating Brazilian Macroeconomic Time Series
Bruno Cavalcante
April 23, 2025

A practical guide to deflating Brazilian time series using the IPCA index, with steps to retrieve data and compute real values for accurate economic analysis.
This tutorial provides a practical, step-by-step guide to deflating Brazilian macroeconomic time series using official inflation data. In high-inflation economies such as Brazil, adjusting nominal figures is critical for conducting accurate and meaningful economic analysis.
Reminder: whenever you're working with nominal data over time, deflating it is a necessary step.
Step 1: Import Required Packages
You need to install the required packages before proceeding:
1from bcb import sgs
2import pandas as pdStep 2: Download Time Series Data
We begin by downloading a nominal time series from the Central Bank of Brazil. This could be GDP, credit volume, or any other relevant macroeconomic or financial indicator.
Examples of series codes include 433 or 20681.
You can find these and other codes on the Central Bank’s time series portal.
Next, we'll download a time series for an official inflation index, such as the IPCA (Índice de Preços ao Consumidor Amplo), which is Brazil’s benchmark consumer price index.
1# Downloading the inflation index (IPCA)
2IPCA = sgs.get({'inflation': 433}, start='2000-01-01')
3
4# Downloading a nominal macroeconomic indicator (e.g., credit card volume)
5credit_card = sgs.get({'nominal_value': 20681}, start='2000-01-01')Here, we need adjust some details in the data format before:
1# Convert from percent to decimal
2IPCA['inflation'] /= 100
3
4Step 3: Prepare the Inflation Index
1# Build monthly index
2IPCA['index'] = IPCA['inflation'] + 1
3IPCA.loc[IPCA.index == IPCA.index[0], 'index'] = 1
4
5# Reset index to work with dates more easily
6IPCA.reset_index(inplace=True)
7
8# Create and compute cumulative inflation factor
9IPCA['cumulative_index'] = 0
10IPCA.loc[0, 'cumulative_index'] = 1
11
12for i in IPCA.index[1:]:
13 IPCA.at[i, 'cumulative_index'] = IPCA.loc[i, 'index'] * IPCA.loc[i - 1, 'cumulative_index']and we obtain:

Step 4: Compute the Deflator
To compute the deflator index, choose a base date and divide the accumulated inflation factor of each period by the factor at the base date.
1# Define base date and compute deflator
2base_date = '2025-01-01'
3IPCA['deflator'] = IPCA['cumulative_index'] / IPCA[IPCA.Date == base_date]['cumulative_index'].values[0]
4
5# Set date as index
6IPCA.set_index('Date', inplace=True)
7
8Step 5: Deflate the Nominal Series
1# Reload nominal series to ensure index match
2credit_card = sgs.get({'nominal_value': 20681}, start='2000-01-01')
3
4# Plot nominal series
5credit_card['nominal_value'].plot(title='Nominal Credit Volume')
6
7# Join with IPCA deflator
8credit_card = credit_card.join(IPCA)
9
10# Calculate real value
11credit_card['real_value'] = credit_card['nominal_value'] / credit_card['deflator']
12
13# Plot both series
14credit_card[['real_value', 'nominal_value']].plot(title='Nominal vs Real Credit Volume')The chart below compares the nominal series with the deflated series, illustrating how inflation affects value over time.


We now have a real, deflated time series that allows for meaningful comparisons across time.
In Summary
Nominal series are affected by inflation distortions.
Deflating adjusts values using an official price index.
This is essential for meaningful economic analysis in inflationary environments.
The complete code is available here.
The Brazilian Central Bank offers a conversion tool on its website. It's useful for validating your calculations as a sanity check.
References:
In this tutorial, we make use of the methodology discussed in the paper: De-Losso, R. (2020). Deflacionamento. Fundação Instituto de Pesquisas Econômicas (FIPE). Boletim de Informações-Temas de economia aplicada, 18-24.