Indian GDP Growth Rate Last 10years Visualization (2009-2019 Q2)

Kuldeep Khatke
4 min readDec 30, 2019

--

Last month, While improving my skills in Data Visualization practices I got an idea to create a project on Indian GDP Growth Rate which is a hot topic at current scenario (Nov-Dec 2019).

You can find the code on below given github link

The scope & purpose of this project is to show ups & downs occurred in Indian GDP Growth rate from the year 2009–2019(Q2). I used line charts for this project.

I’ve divided this project in following steps:

  1. Data Gathering
  2. Data Filtering
  3. Creating Graphs
  4. Data Analysis

Without further ado, let’s begin

Data Gathering

So, First of all I found the required data on Wikipedia — Economy of India page (shown in below image)

Indian GDP Growth Rate Data Source Table

There are many columns related to GDP but as per our requirements we only need Year and GDP growth columns.

So, I fetched this columns using my Web Scrapping skills ;p

# Fetching Wikipedia page html for gathering GDP Growth rate data
wikipedia_page = requests.get("https://en.wikipedia.org/wiki/Economy_of_India").text
# Creating BeautifulSoup instance for returned wikipedia html page soup = BeautifulSoup(wikipedia_page, 'lxml')# Scraping specific GDP grawth rate data table
gdp_table = soup.find('table',{'class':'wikitable sortable'})
# Scrapping specific attributes from the table
# & arranging them in structured format in gdp_data_arr

gdp_data_arr = []
for row in gdp_table.select('tbody > tr')[1:]:
gdp_data_arr.append({
'Year':int(row.select_one('td:nth-child(1)').text.strip()),
'GDP-Growth-Rate(in %)':float(row.select_one('td:nth-child(5)').text.strip().encode('ascii', 'ignore').decode('utf-8').replace('%',''))
})

And after scrapping data from the wikipedia table

Data Filtering

Now, let’s create a pandas dataframe with this scrapped data, filter the the data to get records only from year 2009–2018.

# Creating blank pandas data frame with 'Year' 
# & 'GDP-Growth-Rate(in %)' columns

columns = ['Year', 'GDP-Growth-Rate(in %)']
df = pd.DataFrame(columns=columns)

# Appending gdp_data_arr to the blank dataframe
df = df.append(gdp_data_arr,ignore_index=True)

# Removing data records before year 2009 & after year 2018
df = df[(2009<=df['Year']) & (df['Year']<=2018)]
df = df.reset_index(drop=True)
# Adding 2019 Q2 GDP growth rate
q2_gdp_rate_2019 = {
'Year':2019,
'GDP-Growth-Rate(in %)':float(4.5)
}

df = df.append(q2_gdp_rate_2019,ignore_index=True)

Creating Graphs

Then we will use xkcd mode to show graphs in comic mode.(Optional)

# Apply xkcd mode (Its a comic mode of showing Graphs.)
plt.xkcd()

Now, let’s create our first Line Chart Graph using Matplotlib.

plt.figure(figsize=(10,5))
plt.xlabel('Year')
plt.ylabel('GDP-Growth-Rate(in %)')
plt.xticks([2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019])
plt.yticks([0,1,2,3,4,5,6,7,8,9,10])
values = df['GDP-Growth-Rate(in %)']
plt.plot(df['Year'], df['GDP-Growth-Rate(in %)'],marker='o', color='b')

for ind in df.index:
plt.text(df['Year'][ind], df['GDP-Growth-Rate(in %)'][ind]+.2, df['GDP-Growth-Rate(in %)'][ind], ha="center")

plt.show()
Output chart-1

Data Analysis

Now, let’s do some data analysis by re-searching on given data.

According to India Today Article:

While researching on 2010–2012 GDP Growth rate breakdown, I found the reason behind it is due to poor performance of the manufacturing and farm sectors.

Ouput chart-2

Also the GDP growth rate slipped to 5.3 percent in the fourth quarter of 2011–12, which was lowest in nearly 9 years.

Output chart-3

According to Economic Times Article:

India’s economy grew at its slowest pace in over six years mainly on account of weak manufacturing and a drop in exports due to a global slowdown.

Data sources are

en.wikipedia.org , www.indiatoday.in & economictimes.indiatimes.com

Thanks for reading.

--

--

Kuldeep Khatke

Python Developer. I like to learn about Machine Learning | Data Science | Deep Learning technologies.