twoHelixestwoHelixes Start free

Datasets / World prosperity

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.

Question how has GDP per capita changed over time in Canada, China, Chile, South Africa and Zimbabwe?
GDP per capita over time020k40k60kJan 90Jan 93Jan 96Jan 99Jan 02Jan 05Jan 08Jan 11Jan 14Jan 17Jan 20Jan 23Year DateCanadaChileSouth AfricaChinaZimbabwe
World prosperity — 180 rows charted from 8,415, drawn as a line
How it decided
Finding the data15 ms

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.

Shaping the data37 ms

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.

Choosing the chart14 ms

line. A measure over time with one line per country is a shared-axis line chart.

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.

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_datecountrygdp_per_capita_ppp
1990-01-01Canada40475.098
1991-01-01Canada39139.297
1992-01-01Canada39023.168
1993-01-01Canada39622.465
1994-01-01Canada40952.12
1995-01-01Canada41617.707
1996-01-01Canada41880.535
1997-01-01Canada43241.223