<jupyter_start><jupyter_text>Fastest Growing Country in GDP Per Capita<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
data=pd.read_csv('countries.csv')
data.head(20)
# Data is already sorted on the basis of years, no sorting is done
# Finding the list of all unique countries
countries=set(data.country)

gdp_of_diff_countries=[]
#Calculating the GDP Per Capita Difference in each country in Year 2007 and Year 1952
for c in countries:
    gdp_2007=data[data.country==c].gdpPerCapita.iloc[-1]
    gdp_1952=data[data.country==c].gdpPerCapita.iloc[0]
    gdp_diff=gdp_2007-gdp_1952
    gdp_of_diff_countries.append([c,gdp_diff])
gdp_of_diff_countries=pd.DataFrame(gdp_of_diff_countries,columns=['country','gdpChange'])
top5=gdp_of_diff_countries.sort_values(by=['gdpChange'],ascending=False).head()
# Taking the Top 5 Countries with the maximum change in GDP from 1952-2007
top5.head()
# Isolating Data for Each Country in the Top 5
singapore=data[data.country=='Singapore']
norway=data[data.country=='Norway']
china=data[data.country=='Hong Kong, China']
ireland=data[data.country=='Ireland']
austria=data[data.country=='Austria']<jupyter_output><empty_output><jupyter_text>Plotting the Growth of GDP Per Capita for each of the Top 5 Countries (Singapore, Norway, China, Ireland, Austria)<jupyter_code>plt.title("Growth of GDP Per Capita in Each Country")
plt.plot(singapore.year,singapore.gdpPerCapita/singapore.gdpPerCapita.iloc[0]*100,color='red')
plt.plot(norway.year,norway.gdpPerCapita/norway.gdpPerCapita.iloc[0]*100,color='blue')
plt.plot(china.year,china.gdpPerCapita/china.gdpPerCapita.iloc[0]*100,color='green')
plt.plot(ireland.year,ireland.gdpPerCapita/ireland.gdpPerCapita.iloc[0]*100,color='orange')
plt.plot(austria.year,austria.gdpPerCapita/austria.gdpPerCapita.iloc[0]*100,color='yellow')
plt.legend(['Singapore','Norway','Hong Kong, China','Ireland','Austria'])
plt.xlabel('Year')
plt.ylabel('GDP Per Capita')
plt.show()
# Clearly from the graph we can see that Singapore has reported the fastest growth in GDP Per Capita over the years 1952-2007
# Followed by Hong Kong, China
# Followed by Ireland, then Austria and then Norway<jupyter_output><empty_output><jupyter_text>Analyzing the GDP Per Capita for Singapore<jupyter_code>plt.plot(singapore.year,singapore.gdpPerCapita/singapore.gdpPerCapita.iloc[0]*100,color='red')
plt.plot(singapore.year,singapore.population/singapore.population.iloc[0]*100,color='blue')
plt.legend(['GDP Per Capita','Population'])
plt.title('Growth in GDP Per Capita and Population in Singapore over 1952-2007')
plt.xlabel('Year')
plt.show()<jupyter_output><empty_output><jupyter_text>Fastest Growing Country in terms of GDP<jupyter_code># Finding the list of all unique countries
countries=set(data.country)

gdp_of_diff_countries=[]
#Calculating the GDP Difference in each country in Year 2007 and Year 1952
for c in countries:
    gdp_2007=(data[data.country==c].gdpPerCapita.iloc[-1])*(data[data.country==c].population.iloc[-1])
    gdp_1952=(data[data.country==c].gdpPerCapita.iloc[0])*(data[data.country==c].population.iloc[0])
    gdp_diff=gdp_2007-gdp_1952
    gdp_of_diff_countries.append([c,gdp_diff])
gdp_of_diff_countries=pd.DataFrame(gdp_of_diff_countries,columns=['country','gdp'])
top5gdp=gdp_of_diff_countries.sort_values(by=['gdp'],ascending=False).head()
top5gdp.head()
# Isolating Data for Each Country in the Top 5 in GDP 
usa=data[data.country=='United States']
china=data[data.country=='China']
japan=data[data.country=='Japan']
india=data[data.country=='India']
germany=data[data.country=='Germany']
usa_gdp=usa.gdpPerCapita*usa.population
china_gdp=china.gdpPerCapita*china.population
japan_gdp=japan.gdpPerCapita*japan.population
india_gdp=india.gdpPerCapita*india.population
germany_gdp=germany.gdpPerCapita*germany.population<jupyter_output><empty_output><jupyter_text>Plotting the Growth of GDP for each of the Top 5 Countries (United States, China, Japan, India, Germany)<jupyter_code>plt.title("Growth of GDP in Each Country")
plt.plot(usa.year,usa_gdp/usa_gdp.iloc[0]*100,color='red')
plt.plot(china.year,china_gdp/china_gdp.iloc[0]*100,color='blue')
plt.plot(china.year,japan_gdp/japan_gdp.iloc[0]*100,color='green')
plt.plot(india.year,india_gdp/india_gdp.iloc[0]*100,color='orange')
plt.plot(germany.year,germany_gdp/germany_gdp.iloc[0]*100,color='yellow')
plt.legend(['United States','China','Japan','India','Germany'])
plt.xlabel('Year')
plt.ylabel('GDP')
plt.show()
# From the graph it can be seen that the Fastest Growing Country in terms of GDP is China
# Followed by Japan, then India
# Followed by United States and Germany<jupyter_output><empty_output><jupyter_text>Analyzing GDP for China<jupyter_code>plt.plot(china.year,china_gdp/china_gdp.iloc[0]*100,color='red')
plt.plot(china.year,china.population/china.population.iloc[0]*100,color='blue')
plt.legend(['GDP Per Capita','Population'])
plt.title('Growth in GDP and Population in China over 1952-2007')
plt.xlabel('Year')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1372199087844537, 'fraction_numerical': 0.030339083878643664, 'mean_word_length': 8.481203007518797, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '408772', 'license': 'MIT', 'n_tokens_mistral': 2065, 'n_tokens_neox': 1847, 'n_words': 333, 'path': 'Fastest Growth GDP.ipynb', 'repo_name': 'icoder18/data-visualization-countries', 'size': '5043'}