GDP per capita over time for five countries
The same five countries are followed across every year they report, so the lines stay comparable and no country enters or leaves the story halfway through.
How it decided
World prosperity: 8,415 rows, 8 columns. country, year and gdp_per_capita_ppp for Canada, China, Chile, South Africa and Zimbabwe; missing values are dropped.
8,415 rows in, 180 out across 3 columns. The same five countries are followed across every year they report, so the lines stay comparable and no country enters or leaves the story halfway through.
line. A measure over time with one line per country is a shared-axis line chart.
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.
df["year_date"] = pd.to_datetime(df["year"].astype(str) + "-01-01")
picked = df[df["country"].isin(["Canada", "China", "Chile", "South Africa", "Zimbabwe"])]
picked = picked.dropna(subset=["gdp_per_capita_ppp"])
result = picked[["year_date", "country", "gdp_per_capita_ppp"]].sort_values(["country", "year_date"])
What it charted
180 rows out of 8,415, 3 columns. First 8 shown.
| year_date | country | gdp_per_capita_ppp |
|---|---|---|
| 1990-01-01 | Canada | 40475.098 |
| 1991-01-01 | Canada | 39139.297 |
| 1992-01-01 | Canada | 39023.168 |
| 1993-01-01 | Canada | 39622.465 |
| 1994-01-01 | Canada | 40952.12 |
| 1995-01-01 | Canada | 41617.707 |
| 1996-01-01 | Canada | 41880.535 |
| 1997-01-01 | Canada | 43241.223 |