Data Visualization: How was inflation in Brazil for the past presidents?
Inflation in Brazil has been growing alarmingly
Introduction
This project was developed and inspired by the Dataquest guide project. In it, the average monthly IPCA data from 2003 to 2022 was selected in order to analyze its variation for each president in that period.
The IPCA (“Índice de Preço ao Consumidor Amplo”, Broad Consumer Price Index) aims to measure the inflation of a set of products and services sold in retail, referring to the personal consumption of families. Currently (2022) Brazil is facing one of the worst inflation rates, so I produce this article to analyze the inflation values for the last presidents.
Database
All data was taken from the IBGE (“Instituto Brasileiro de Geografia e Estatística”, Brazilian Institute of Geography and Statistics) constitutes the main provider of data and information in the country, and meets the needs of the most diverse segments of civil society, as well as federal, state and municipal government agencies.
Pre-processing and cleaning
Important libraries for the program
import loggingimport pandas as pdimport streamlit as stimport matplotlib.pyplot as pltfrom matplotlib import style
Reading the data
def read_data(file_path):try: assert isinstance(file_path, str) df_func = pd.read_csv(file_path, sep=";") shape = df_func.shape[0] logging.info(f"SUCCESS: There are {shape} rows in your dataframe") return df_funcexcept FileNotFoundError: logging.error(f"ERROR: we were not able to find {file_path}") return Noneexcept AssertionError: logging.error("ERROR: Error type") return None
df_ipca = read_data('ipca.csv')
Cleaning columns
df_ipca.rename(columns={'IPCA dessazonalizado - Variação mensal (%)': 'IPCA',},inplace=True)df_ipca['IPCA'] = df_ipca['IPCA'].str.replace(',', '.')df_ipca['IPCA'] = df_ipca['IPCA'].astype(float)df_ipca['date'] = df_ipca['Mês'].str.split(' ').str[1]df_ipca['date'] = pd.to_datetime(df_ipca['date'], format='%Y')
Data visualization
To see the graphic production code in detail, you can access my GitHub which will contain all the repository and documentation necessary to generate the graphic.
Conclusion
As we can see, the governments of president Lula and Temer, had a tendency to reduce inflation, on the other hand, the government of Dilma had an increase at the end of her term, most likely caused by her impeachment and, last but not least, we have the current government (Bolsonaro)which since 2021 has been increasing in inflation values