Life expectancy against GDP per capita, latest year
One point per country, each at its most recent year where both measures are present, so gaps in either series cannot masquerade as zeros and pull a country to the corner of the plot.
How it decided
World prosperity: 8,415 rows, 8 columns. gdp_per_capita_ppp and life_expectancy in each country's latest year with both; missing values are dropped.
8,415 rows in, 198 out across 2 columns. One point per country, each at its most recent year where both measures are present, so gaps in either series cannot masquerade as zeros and pull a country to the corner of the plot.
scatter. Two measures with no grouping is a scatter: one point per country shows the relationship directly.
Palette, spacing, axis titles and legend placement applied. 0 issues found.
The transformation
This is the code, not a description of it — the chart above was drawn from what it returns, and the notebook download runs the same lines against the same file.
d = df.dropna(subset=["gdp_per_capita_ppp", "life_expectancy"])
latest = d.loc[d.groupby("country")["year"].idxmax()]
result = latest[["gdp_per_capita_ppp", "life_expectancy"]].reset_index(drop=True)
What it charted
198 rows out of 8,415, 2 columns. First 8 shown.
| gdp_per_capita_ppp | life_expectancy |
|---|---|
| 1983.8126 | 66.0346 |
| 20501.646 | 79.6019 |
| 15159.324 | 76.261 |
| 64631.297 | 84.0406 |
| 8597.539 | 64.617 |
| 28712.396 | 77.5976 |
| 27230.396 | 77.3947 |
| 19402.752 | 75.6827 |