twoHelixestwoHelixes Start free

Datasets / City air quality

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.

Question which cities have the worst PM2.5?
Average PM2.5 by city0204060DelhiTokyoCairoLondonSao PauloMexico CityChicagoLos AngelesPm25 Ug M3
City air quality — 8 rows charted from 96, drawn as a hbar
How it decided
Finding the data880 ms

City air quality: 96 rows, 11 columns. city and pm25_ug_m3; the ranking uses all twelve monthly observations.

Shaping the data3 ms

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.

Choosing the chart3 ms

hbar. City names are labels and PM2.5 is one measure, so sorted horizontal bars read best.

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.

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.

citypm25_ug_m3
Delhi56.1833
Tokyo42.6833
Cairo41.6833
London29.1833
Sao Paulo24.6833
Mexico City20.1833
Chicago15.6833
Los Angeles11.1833