twoHelixestwoHelixes Start free

Datasets / World health and longevity

Highest life expectancy, latest year per country

Each country contributes its own latest observed value, so the ranking is not distorted by the different years in which each series ends.

Question which countries have the highest life expectancy in the latest year?
Highest life expectancy050100150MonacoHong KongSouth KoreaFrench PolynesiaSwitzerlandSingaporeSpainGibraltarFranceMaltaSwedenVaticanLife Expectancy
World health and longevity — 25 rows charted from 8,229, drawn as a hbar
How it decided
Finding the data14 ms

World health and longevity: 8,229 rows, 8 columns. country, year and life_expectancy; missing values are dropped, never read as zero.

Shaping the data17 ms

8,229 rows in, 25 out across 2 columns. Each country contributes its own latest observed value, so the ranking is not distorted by the different years in which each series ends.

Choosing the chart13 ms

hbar. A ranking of long country names is a horizontal bar chart, capped at twenty-five rows so the top of the distribution stays readable.

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.

latest = df.dropna(subset=["life_expectancy"]).sort_values("year")
latest = latest.groupby("country", as_index=False).tail(1)
result = (latest[["country", "life_expectancy"]]
          .sort_values("life_expectancy", ascending=False)
          .head(25)
          .reset_index(drop=True))

What it charted

25 rows out of 8,229, 2 columns. First 8 shown.

countrylife_expectancy
Monaco86.3724
San Marino85.7062
Hong Kong85.5106
Japan84.7123
South Korea84.3288
Saint Barthelemy84.2901
French Polynesia84.0698
Andorra84.0406