twoHelixestwoHelixes Start free

Datasets / World prosperity

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.

Question which countries have the highest GDP per capita in the latest year?
GDP per capita in the latest year050k100k150kSingaporeLuxembourgQatarNorwayGuyanaBruneiDenmarkNetherlandsSan MarinoHong KongGdp Per Capita Ppp
World prosperity — 20 rows charted from 8,415, drawn as a hbar
How it decided
Finding the data13 ms

World prosperity: 8,415 rows, 8 columns. country, year and gdp_per_capita_ppp; missing values are dropped, never read as zero.

Shaping the data15 ms

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.

Choosing the chart6 ms

hbar. Country names are labels and income is one measure, so sorted horizontal bars read best.

Applying defaults1 ms

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.

countrygdp_per_capita_ppp
Singapore139592.61
Ireland131338.44
Luxembourg127420.6
Macao117098.27
Qatar110135.695
Bermuda104299.945
Norway95173.43
Switzerland85732.11