Datasets / World health and longevity
Life expectancy over time for five countries
Five named countries with very different starting points on one year axis show how their paths diverge over the same period.
How it decided
World health and longevity: 8,229 rows, 8 columns. year, country and life_expectancy for the five named countries; missing years are dropped.
8,229 rows in, 170 out across 3 columns. Five named countries with very different starting points on one year axis show how their paths diverge over the same period.
line. A measure over time with one line per country, capped at five series so the lines stay distinguishable.
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.
result = (df[df["country"].isin(["Canada", "Switzerland", "Zimbabwe", "Portugal", "Cambodia"])].dropna(
subset=["life_expectancy"])
[["year", "country", "life_expectancy"]])
What it charted
170 rows out of 8,229, 3 columns. First 8 shown.
| year | country | life_expectancy |
|---|---|---|
| 1990 | Canada | 77.4333 |
| 1991 | Canada | 77.5939 |
| 1992 | Canada | 77.8525 |
| 1993 | Canada | 77.7251 |
| 1994 | Canada | 77.9007 |
| 1995 | Canada | 78.0206 |
| 1996 | Canada | 78.272 |
| 1997 | Canada | 78.4649 |