# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import pandas as pd
import matplotlib.pyplot as plt

data = pd.read_csv("../countries.csv")
data.head()

# +
# Calculates GDP per Country
data['gdpTotal'] = data.population * data.gdpPerCapita

# Get the top 10 countries per GDP
country_gdp = data.sort_values('gdpTotal', ascending=False)
top_10_gdp = country_gdp[country_gdp.year == 2007].head(10)

# Sumarize their names for usage in the for loop
top_10_gdp = set(top_10_gdp.country)

# +
# Sort the data by Year
data.sort_values('year', ascending=True)
legend = []

for country in set(top_10_gdp):
    country_data = data[data.country == country]
    plt.plot(country_data.year, country_data.gdpTotal / country_data.gdpTotal.iloc[0], label=country)
    legend.append(country)
    
# Change the figure (graph) zise
fig = plt.gcf()
fig.set_size_inches(20, 12)

plt.legend(legend)
plt.show()
# -



StarcoderdataJupyterScriptsDedupFiltered