GDP per capita in the latest year, top 20
Each country contributes a single row: its most recent year with a GDP per capita value, so the ranking compares like with like instead of mixing years.
How it decided
World prosperity: 8,415 rows, 8 columns. country, year and gdp_per_capita_ppp; missing values are dropped, never read as zero.
8,415 rows in, 20 out across 2 columns. Each country contributes a single row: its most recent year with a GDP per capita value, so the ranking compares like with like instead of mixing years.
hbar. Country names are labels and income is one measure, so sorted horizontal bars read best.
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"])
latest = d.loc[d.groupby("country")["year"].idxmax()]
result = (latest.sort_values("gdp_per_capita_ppp", ascending=False)
.head(20)[["country", "gdp_per_capita_ppp"]])
What it charted
20 rows out of 8,415, 2 columns. First 8 shown.
| country | gdp_per_capita_ppp |
|---|---|
| Singapore | 139592.61 |
| Ireland | 131338.44 |
| Luxembourg | 127420.6 |
| Macao | 117098.27 |
| Qatar | 110135.695 |
| Bermuda | 104299.945 |
| Norway | 95173.43 |
| Switzerland | 85732.11 |