Life Expectancy vs Gross Domestic Product using Data Analytics! | by Dhruvil Shah | Towards Data Science

Data Analytics refers to data processing methods to improve productivity and business benefit. Data is derived from various sources and is cleaned and categorized to interpret different patterns of actions. Here, the relation between the terms GDP and Life Expectancy at Birth Year is analyzed with the help of the last 20 years data of six different countries.
GDP: Gross Domestic Product (GDP) is the overall monetary or consumer value of all finished goods and services produced within the boundaries of a nation over a given period. It acts as a large measure of overall domestic output, as a detailed scorecard of the economic health of the country. GDP is measured in US dollars.Life Expectancy at Birth Year (LEABY): The word “Life Expectancy” refers to how many years a person may expect to live. By definition, life expectancy is based on an estimation of the average age at which members of a given demographic group will be at death.
GDP: Gross Domestic Product (GDP) is the overall monetary or consumer value of all finished goods and services produced within the boundaries of a nation over a given period. It acts as a large measure of overall domestic output, as a detailed scorecard of the economic health of the country. GDP is measured in US dollars.
Life Expectancy at Birth Year (LEABY): The word “Life Expectancy” refers to how many years a person may expect to live. By definition, life expectancy is based on an estimation of the average age at which members of a given demographic group will be at death.
The data used in this project is gathered from the World Bank. This project aims to try and identify the relationship between the GDP and Life Expectancy of six countries namely, Australia, China, Germany, India, the United States of America, and Zimbabwe with the help of Data visualization.
Find the code of this project here and connect with me on LinkedIn. Let’s get to the coding part.
Violin plots help us to visualize and compare more than one distributions at a time. There are two symmetrical ‘KDE — Kernel Density Estimator — plots’ along the middle line. The ‘black thick line’ at the center shows the interquartile range while the lines that extend from it to the ends represent a 95% confidence interval. The white dot in the middle shows the median of the distribution. Learn more about violin plots here.
Below is the code for creating the violin plots of each of the six countries.
from matplotlib import pyplot as pltimport pandas as pdimport seaborn as snsdf = pd.read_csv("final.csv")fig = plt.subplots(figsize=(12, 7))sns.violinplot(data=df, x='Country', y='LEABY', fontsize='large', fontweight='bold')plt.savefig("violin.png",bbox_inches='tight')
Output:
We can see that variance is the highest in the data of Zimbabwe country and the lowest in the United States. Also, the median Life Expectancy is the largest in Australia and the lowest in Zimbabwe.
A FacetGrid takes in a function and creates individual graphs for which you specify the arguments.
Next, to see the correlation between GDP and LEABY, let’s see the facet grid of scatter graphs, mapping GDP as a function of Life Expectancy by country. Below are the matplotlib scatter plots for the plot (LEABY vs GDP).
g = sns.FacetGrid(df, col='Year', hue='Country', col_wrap=4, size=2)g = (g.map(plt.scatter, 'GDP', 'LEABY', edgecolor="w").add_legend())
Scatter plots are easy to interpret. We can notice the changes over the last 20 years in the countries from the plot above. China and the United States are the countries that have moved most along the x-axis i.e. GDP has increased over the years while Zimbabwe has moved most along the y-axis i.e. life expectancy there has increased over time. Further, Life expectancy in Australia and the United States seems to be constant for the last 20 years.
Furthermore, a great way to visualize a variable over time is by using a line plot. Now, instead of the scatter plots if we use line plots for GDP and Life expectancy individually we could more easily see the changes over time. Below is the FacetGrid of line graphs mapping GDP by country.
g3 = sns.FacetGrid(df, col="Country", col_wrap=3, size=4)g3 = (g3.map(plt.plot, "Year", "GDP").add_legend())
United States of America has the highest GDP among these countries and it steadily seems to be increasing over the years. As we can see that the GDP in China has drastically increased in the past 10 years, it is interesting to know what happened in China that made this sudden change? There are many reasons behind that, which you can find in the below article.
www.weforum.org
Now let’s look at a similar plot as above for LEABY. Below is the FacetGrid of line graphs mapping Life expectancy by country.
g3 = sns.FacetGrid(df, col="Country", col_wrap=3, size=4)g3 = (g3.map(plt.plot, "Year", "LEABY").add_legend())
It is from 2010–2015 when there is a huge change in the Life expectancy of these six countries. The United States has had the least change in life expectancy over time, could this be the outcome of having high GDP? But then there is the case of Australia where the GDP is lower compared to other ones’, but the life expectancy is still almost equal to that of the United States. It seems that the relation between GDP and Life expectancy is not that simple.
“It’s pretty surprising,” says Adriana Lleras-Muney, a professor of economics at the Los Angeles University of California. “We know that people live longer in rich countries than people in poor countries. There is a strong relationship between GDP and life expectancy which indicates that more income is better. And yet, when the economy is doing well, when it is rising higher than normal, we find that more people are dying.” That is to say, becoming rich has great benefits. But the method of being wealthy, it sounds risky.
To conclude, the economists agree that, when the economic performance of a country — its GDP — is higher than anticipated, mortality rates are often higher than expected. The relationship is evident but the impact size is small. Adults are about 1 percent more likely to die in a year when GDP is about 5 percent above average — which is a decent boom. Read the below article for a better understanding of the relation between GDP and Life expectancy.