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.
How it decided
World climate and energy: 8,037 rows, 6 columns. country, year and co2_tonnes_per_person for the five named countries.
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.
line. Time on x with one line per country is the shared-axis line chart; five series stays inside the palette limit.
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_date | country | co2_tonnes_per_person |
|---|---|---|
| 1990-01-01 | Brazil | 1.4661 |
| 1990-01-01 | China | 2.1529 |
| 1990-01-01 | India | 0.6682 |
| 1990-01-01 | United Kingdom | 10.4927 |
| 1990-01-01 | United States | 20.2537 |
| 1991-01-01 | Brazil | 1.5119 |
| 1991-01-01 | China | 2.2371 |
| 1991-01-01 | India | 0.6962 |