twoHelixestwoHelixes Start free

Datasets / World climate and energy

CO2 per person over time for five countries

Five named countries on the same year axis, so the shapes and starting points of the longer-run trends can be compared without a field of unreadable lines.

Question how has CO2 per person trended in China, the United States, India, the United Kingdom and Brazil?
CO2 per person by country05101520Jan 90Jan 93Jan 96Jan 99Jan 02Jan 05Jan 08Jan 11Jan 14Jan 17Jan 20Jan 23Year DateUnited StatesUnited KingdomChinaBrazilIndia
World climate and energy — 175 rows charted from 8,037, drawn as a line
How it decided
Finding the data13 ms

World climate and energy: 8,037 rows, 6 columns. country, year and co2_tonnes_per_person for the five named countries.

Shaping the data21 ms

8,037 rows in, 175 out across 3 columns. Five named countries on the same year axis, so the shapes and starting points of the longer-run trends can be compared without a field of unreadable lines.

Choosing the chart18 ms

line. Time on x with one line per country is the shared-axis line chart; five series stays inside the palette limit.

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.

names = ["China", "United States", "India", "United Kingdom", "Brazil"]
df = df[df["country"].isin(names)].dropna(subset=["co2_tonnes_per_person"])
df["year_date"] = pd.to_datetime(df["year"].astype(str) + "-01-01")
result = df[["year_date", "country", "co2_tonnes_per_person"]].sort_values(["year_date", "country"])
result = result.reset_index(drop=True)

What it charted

175 rows out of 8,037, 3 columns. First 8 shown.

year_datecountryco2_tonnes_per_person
1990-01-01Brazil1.4661
1990-01-01China2.1529
1990-01-01India0.6682
1990-01-01United Kingdom10.4927
1990-01-01United States20.2537
1991-01-01Brazil1.5119
1991-01-01China2.2371
1991-01-01India0.6962