image_output_2.png image_output_1.png
import pandas as pd

life = pd.read_csv('/kaggle/input/life-expectancy-who-updated/Life-Expectancy-Data-Updated.csv')

life[['Adult_mortality', 'Infant_deaths', 'Under_five_deaths']] = life[['Adult_mortality', 'Infant_deaths', 'Under_five_deaths']] / 10

groupyears = life.groupby('Year')['Country'].value_counts()
groupyears = groupyears.unstack()
missing_country = []
for index, rows in groupyears.iterrows():
    for col in groupyears.columns:
        if groupyears.loc[index, col] != 1:
            missing_country.append([index, col])
        else:
            None

average_timeline = life.groupby('Year')['Life_expectancy'].mean()
average_compare = life[life['Year'].isin([2000, 2015])].groupby(['Year', 'Region', 'Country'])['Life_expectancy'].median()

average_timeline = life.groupby('Year')['Life_expectancy'].mean()
average_compare = life[life['Year'].isin([2000, 2015])].groupby(['Year', 'Region', 'Country'])['Life_expectancy'].median()

gdp_infant = life.groupby(['Country', 'Year'])[['GDP_per_capita', 'Infant_deaths', 'Under_five_deaths']].mean()
print('GDP per capita and infant & underfive year children mortality rates (per 1000) of countries around the world, since 2000-2015.')
gdp_infant = gdp_infant.reset_index()
print(gdp_infant)
gdp_infant_avg = life.groupby('Country')[['GDP_per_capita', 'Infant_deaths', 'Under_five_deaths']].mean()
print('Average GDP per capita and infant & underfive year children mortality rates (per 1000) of countries around the world, since 2000-2015.')
print(gdp_infant_avg)