# Life Expectancy By Country

I am wondering why I can’t find the quartiles of my gpd column after splitting it. Do I need to divide quartiles into 4ths?

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

life_expectancy = data[“Life Expectancy”]
gdp = data[“GDP”]
life_expectancy_quartiles = np.quantile(life_expectancy, [0.25, 0.5 , 0.75])
median_gdp = np.median(gdp)
print(median_gdp)
#print(np.quantile(gdp,0.5))
print(life_expectancy_quartiles)
plt.hist(life_expectancy)
#plt.show()
low_gdp = data[data[‘GDP’] <= median_gdp]
#print(low_gdp)
high_gdp = data[data[‘GDP’] > median_gdp]
low_gdp_quartiles = np.quantile(low_gdp[“Life Expectancy”], [0.25, 0.5, 0.75])
high_gdp_quartiles = np.quantile(high_gdp[“Life Expectancy”], [0.25, 0.5, 0.75])
#print(low_gdp[“Life Expectancy”])
#print(low_gpd_quartiles)
print(high_gpd_quartiles)

This is the part of the code I think i’m having trouble on. I I thought that [0.25, 0.5, 0.75] would give the quartiles for Low GDP and High GDP. However it doesn’t seem to really work the way i want it to.

Thanks to whoever contributes.

I know this is a dated, post, just wondering if you got it? I’m guessing yes. This is what I did: low_gdp = data[data[‘GDP’] <= np.round_((median_gdp),6)]
Because median_gdp is a numpy array, the value needs to be extracted from the array. The numpy round function is probably not necessary, put it in just in case.