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.
How it decided
World health and longevity: 8,229 rows, 8 columns. country, year and life_expectancy; missing values are dropped, never read as zero.
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.
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.
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.
| country | life_expectancy |
|---|---|
| Monaco | 86.3724 |
| San Marino | 85.7062 |
| Hong Kong | 85.5106 |
| Japan | 84.7123 |
| South Korea | 84.3288 |
| Saint Barthelemy | 84.2901 |
| French Polynesia | 84.0698 |
| Andorra | 84.0406 |