Datasets / World health and longevity
Change in life expectancy since 1990
Change is measured per country between its 1990 value and its latest observed value, so countries with different coverage are still compared on their own history.
How it decided
World health and longevity: 8,229 rows, 8 columns. country, year and life_expectancy in 1990 and in the latest year per country.
8,229 rows in, 25 out across 4 columns. Change is measured per country between its 1990 value and its latest observed value, so countries with different coverage are still compared on their own history.
hbar. A per-country before-and-after difference is one bar per country, sorted by the size of the change.
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.
base = df[df["year"] == 1990][["country", "life_expectancy"]].dropna()
base = base.rename(columns={"life_expectancy": "life_1990"})
latest = df.dropna(subset=["life_expectancy"]).sort_values("year")
latest = latest.groupby("country", as_index=False).tail(1)
latest = latest[["country", "life_expectancy"]].rename(
columns={"life_expectancy": "life_latest"})
joined = base.merge(latest, on="country", how="inner")
joined["change"] = joined["life_latest"] - joined["life_1990"]
result = (joined.sort_values("change", ascending=False)
.head(25)
.reset_index(drop=True))
What it charted
25 rows out of 8,229, 4 columns. First 8 shown.
| country | life_1990 | life_latest | change |
|---|---|---|---|
| South Sudan | 28.6275 | 57.6174 | 28.9899 |
| Falkland Islands | 53.336 | 79.2132 | 25.8772 |
| Liberia | 37.6435 | 62.1625 | 24.519 |
| Malawi | 43.5748 | 67.3535 | 23.7787 |
| Angola | 41.8542 | 64.617 | 22.7628 |
| East Timor | 45.1849 | 67.6894 | 22.5045 |
| Ethiopia | 45.1166 | 67.315 | 22.1984 |
| Afghanistan | 45.1183 | 66.0346 | 20.9163 |