Cities ranked by average PM2.5
Monthly observations are averaged by city and sorted from the most polluted, so the ranking is not dominated by a single month.
How it decided
City air quality: 96 rows, 11 columns. city and pm25_ug_m3; the ranking uses all twelve monthly observations.
96 rows in, 8 out across 2 columns. Monthly observations are averaged by city and sorted from the most polluted, so the ranking is not dominated by a single month.
hbar. City names are labels and PM2.5 is one measure, so sorted horizontal bars read best.
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.groupby("city", as_index=False)["pm25_ug_m3"].mean() .sort_values("pm25_ug_m3", ascending=False))
What it charted
8 rows out of 96, 2 columns. First 8 shown.
| city | pm25_ug_m3 |
|---|---|
| Delhi | 56.1833 |
| Tokyo | 42.6833 |
| Cairo | 41.6833 |
| London | 29.1833 |
| Sao Paulo | 24.6833 |
| Mexico City | 20.1833 |
| Chicago | 15.6833 |
| Los Angeles | 11.1833 |