Datasets:
Download README.md from junaid008/pak_air_quality: direct link, hf CLI and curl.
- Browser
- Download file 15.9 kB
-
https://huggingface.co/datasets/junaid008/pak_air_quality/resolve/main/README.md
- Command line
-
hf download hf://datasets/junaid008/pak_air_quality/README.md
-
curl -L -o README.md https://huggingface.co/datasets/junaid008/pak_air_quality/resolve/main/README.md
license: cc-by-4.0
pretty_name: >-
Pakistan daily air quality (modelled, CAMS global) + weather, 10 cities,
2022-08 to 2025-12
language:
- en
task_categories:
- tabular-regression
tags:
- pakistan
- pakdata
- tabular
- air-quality
- pollution
- smog
- pm2.5
- time-series
size_categories:
- 10K<n<100K
configs:
- config_name: default
data_files:
- split: train
path: data/train.parquet
Pakistan daily air quality (modelled, CAMS global) + weather, 10 cities, 2022-08 to 2025-12
Part of pakdata, a collection of real, openly licensed Pakistan-specific datasets for machine learning. Every value comes from the named public source below; nothing is synthetic or AI-generated.
| Rows | 12,450 |
| Default target | pm2_5_ugm3 (regression) |
| Source | Open-Meteo Air Quality API (CAMS global atmospheric composition forecasts, Copernicus/ECMWF) + Open-Meteo Historical Weather API (ERA5/ERA5-Land, Copernicus C3S) |
| License | CC BY 4.0 |
| Snapshot | 2026.11 |
Load it
# pakdata (scikit-learn style, works offline) pip install pakdata
from pakdata import load_pak_air_quality
X, y = load_pak_air_quality(return_X_y=True)
# Hugging Face datasets (also gives PyTorch / TensorFlow / JAX formats)
from datasets import load_dataset
ds = load_dataset("junaid008/pak_air_quality", split="train")
torch_ds = ds.with_format("torch")
# pandas / Polars / DuckDB, straight from the Hub
import pandas as pd; df = pd.read_parquet("hf://datasets/junaid008/pak_air_quality/data/train.parquet")
import polars as pl; df = pl.read_parquet("hf://datasets/junaid008/pak_air_quality/data/train.parquet")
import duckdb; duckdb.sql("SELECT * FROM 'hf://datasets/junaid008/pak_air_quality/data/train.parquet'")
Plain CSV (Excel, R, Julia, MATLAB, SPSS, anything):
https://huggingface.co/datasets/junaid008/pak_air_quality/resolve/main/csv/pak_air_quality.csv
df <- read.csv("https://huggingface.co/datasets/junaid008/pak_air_quality/resolve/main/csv/pak_air_quality.csv")
JSON API (JavaScript, mobile apps, any language):
https://datasets-server.huggingface.co/rows?dataset=junaid008/pak_air_quality&config=default&split=train&offset=0&length=100
Features used by pakdata: city, province, latitude_deg, longitude_deg, year, month, day_of_year, day_of_week, no2_ugm3, o3_ugm3, so2_ugm3, co_ugm3, dust_ugm3, aod_550nm, temp_max_c, temp_min_c, precip_mm, wind_speed_max_kmh, rel_humidity_mean_pct, boundary_layer_height_mean_m, wind_direction_dominant_deg
Kept in the table but not used as features (ids, raw dates, or columns that would leak the target): date, pm2_5_max_ugm3, pm10_ugm3
Data card
The full data card (column meanings and units, how it was built, caveats, suggested tasks):
.. _pak_air_quality_dataset:
Pakistan daily air quality (modelled, CAMS global) and weather, 10 cities
-------------------------------------------------------------------------
**IMPORTANT: this is MODELLED data, not measurements.** Every pollutant value is the
output of the Copernicus Atmosphere Monitoring Service (CAMS) global atmospheric
composition *forecast* model, sampled at the model grid cell nearest each city. No
ground-station (EPA Punjab, Pak-EPA, US consulate, PurpleAir, ...) readings are included.
Weather columns are reanalysis (ERA5 / ERA5-Land), also model-based.
**Data Set Characteristics:**
:Number of Instances: 12,450 (10 cities x 1,245 days)
:Number of Attributes: 21 features + target (25 columns in ``frame``; ``date``,
``pm2_5_max_ugm3`` and ``pm10_ugm3`` are kept in the frame but excluded from ``X``)
:Default target: ``pm2_5_ugm3`` (daily mean PM2.5, micrograms per cubic metre)
:Time coverage: 2022-08-05 to 2025-12-31, daily, every day present for every city.
2022-08-04 is the earliest date for which the Open-Meteo Air Quality API serves CAMS
global data (hourly values begin 2022-08-04 05:00 PKT = 00:00 UTC; checked 2026-11-29);
that partial first day is dropped, so the first complete day is 2022-08-05.
:Geographic coverage: Lahore, Karachi, Islamabad, Peshawar, Faisalabad, Multan, Quetta,
Gujranwala, Rawalpindi, Hyderabad (Sindh). Point = GeoNames city coordinate.
:Source: Open-Meteo Air Quality API, https://air-quality-api.open-meteo.com/v1/air-quality
(``domains=cams_global``; docs https://open-meteo.com/en/docs/air-quality-api), which
serves CAMS global atmospheric composition forecasts (ECMWF / Copernicus, ~0.4 deg,
3-hourly, interpolated to hourly by Open-Meteo). Weather: Open-Meteo Historical Weather
API, https://archive-api.open-meteo.com/v1/archive (default ``best_match``: ERA5 and
ERA5-Land, Copernicus C3S). City coordinates: Open-Meteo Geocoding API (GeoNames).
:License: CC BY 4.0 (https://open-meteo.com/en/licence ;
https://creativecommons.org/licenses/by/4.0/). Attribution to Open-Meteo and to
Copernicus (CAMS, C3S) is required - see Citation below.
:Snapshot: 2026.11 (retrieved 2026-11-29)
**Columns:**
- ``date`` (YYYY-MM-DD): local calendar day, Pakistan Standard Time (UTC+5). Excluded from X.
- ``city`` (category): city name.
- ``province`` (category): GeoNames admin-1 (Punjab, Sindh, Khyber Pakhtunkhwa,
Balochistan, Islamabad).
- ``latitude_deg``, ``longitude_deg`` (degrees): GeoNames coordinate that was queried
(the APIs snap it to their nearest grid cell).
- ``year``, ``month``, ``day_of_year``, ``day_of_week`` (0 = Monday): derived from ``date``.
- ``pm2_5_ugm3`` (ug/m3): **target**. Daily mean of hourly PM2.5 near the surface.
- ``pm2_5_max_ugm3`` (ug/m3): daily maximum hourly PM2.5. *Excluded from X (leaks target).*
- ``pm10_ugm3`` (ug/m3): daily mean PM10. *Excluded from X: PM10 contains PM2.5 by
definition and in CAMS both are sums of the same aerosol species.*
- ``no2_ugm3``, ``o3_ugm3``, ``so2_ugm3``, ``co_ugm3`` (ug/m3): daily means of nitrogen
dioxide, ozone, sulphur dioxide and carbon monoxide near the surface (10 m).
- ``dust_ugm3`` (ug/m3): daily mean mineral-dust concentration near the surface.
- ``aod_550nm`` (dimensionless): daily mean total-column aerosol optical depth at 550 nm.
- ``temp_max_c``, ``temp_min_c`` (deg C): daily max / min 2 m air temperature.
- ``precip_mm`` (mm): daily precipitation sum.
- ``wind_speed_max_kmh`` (km/h): daily maximum 10 m wind speed.
- ``rel_humidity_mean_pct`` (%): daily mean 2 m relative humidity.
- ``boundary_layer_height_mean_m`` (m): daily mean of hourly planetary boundary layer
height. **1,830 missing values** (2024-01-01 to 2024-07-01 for every city): the source
API returns null for this variable over that period (verified with ``models=era5`` too).
- ``wind_direction_dominant_deg`` (degrees, 0/360 = from north): dominant daily 10 m
wind direction. Circular - consider sin/cos encoding.
**CAMS source outage, 2022-12-13 to 2022-12-16 (40 rows with empty pollutant values).**
From 2022-12-13 17:00 to 2022-12-16 04:00 PKT (12:00 UTC on 12-13 to 23:00 UTC on 12-15),
the source API returns near-zero values for every CAMS variable in all 10 cities. PM2.5
is 0.5-0.9 ug/m3, NO2 = 0, dust = 0 and AOD is about 0.04. This falls in the middle of the
smog season; in Lahore, hourly PM2.5 drops from about 29 to 0.7 ug/m3 and later jumps from
0.5 to 76. These are not real conditions. Direct re-fetches on 2026-11-29 confirmed that the
source serves these values, so this is not a build bug. The build script sets every CAMS
hourly value in that window to missing. Under the 20-of-24-hours rule, all 9 pollutant
columns (``pm2_5_ugm3``, ``pm2_5_max_ugm3``, ``pm10_ugm3``, ``no2_ugm3``, ``o3_ugm3``,
``so2_ugm3``, ``co_ugm3``, ``dust_ugm3``, ``aod_550nm``) are then empty on 2022-12-13,
12-14, 12-15 and 12-16 for every city: 40 rows, with 40 missing values per column. The
rows themselves are kept (weather is still present), so every city still has 1,245 rows.
**The default target therefore has 40 missing values.** Drop them before fitting, for
example ``df = df.dropna(subset=["pm2_5_ugm3"])``, or ``mask = ~np.isnan(y)``.
No other column has missing values.
**How it was built:** ``scripts/build_pak_air_quality.py``. (1) Each city name is
geocoded with the Open-Meteo Geocoding API, keeping the Pakistani match with the largest
population. (2) One Air Quality API request per city fetches hourly pm2_5, pm10,
nitrogen_dioxide, ozone, sulphur_dioxide, carbon_monoxide, dust and aerosol_optical_depth
(``domains=cams_global``, ``timezone=Asia/Karachi``) from 2022-08-04 to 2025-12-31.
(3) Hourly values are grouped by local calendar day; the mean (and for PM2.5 also the
max) is kept only if at least 20 of 24 hours are non-missing, otherwise the cell is left
empty. (3b) CAMS hourly values in the documented 2022-12-13/16 outage window (see
above) are set to missing before aggregation; the script asserts that the window really
contains the artifact (NO2 = 0, dust = 0, PM2.5 < 2) and that the hours just outside it
are normal. (4) One Historical Weather API request per city fetches the daily weather
variables plus hourly boundary_layer_height (aggregated to a daily mean with the same
20-hour rule). (5) Air quality and weather are joined on city + date, leading days before
the first CAMS value are dropped, calendar parts are added, values are rounded (2 d.p.,
AOD 4 d.p.) and rows are sorted by city, then date.
**Caveats and known biases:**
- *Modelled, not measured.* CAMS global runs at ~40-45 km resolution: one grid cell spans
an entire city plus surrounding countryside, so street-level and neighbourhood hotspots
are smoothed out.
- *Underestimation of extreme smog.* Station networks in Lahore regularly report
winter daily PM2.5 of several hundred ug/m3; the maximum daily mean in this whole
dataset is 288 ug/m3 (Faisalabad, 2024-12-22). CAMS global is known to underestimate PM2.5 peaks over the Indo-Gangetic
Plain, where emission inventories for crop-residue burning, brick kilns and local
traffic/industry are uncertain. Treat absolute levels with caution; seasonal and
day-to-day *patterns* are more trustworthy than exact numbers.
- *Forecast, not reanalysis.* Open-Meteo archives the operational CAMS global forecasts
(run twice daily, assimilating satellite data). Model upgrades over 2022-2025 can cause
small discontinuities; the CAMS EAC4 reanalysis is not what is served here.
- *Islamabad and Rawalpindi share a CAMS grid cell*: their PM2.5, PM10, NO2, O3, SO2,
dust and AOD values are identical on every day (weather differs slightly). A random train/test split will
therefore put a near-copy of each test row in the training set and inflate scores. Use
a time-based split or ``GroupKFold`` by city for honest evaluation.
- *Possible CO discontinuity on 2024-10-26.* Up to 2024-10-25 Islamabad and Rawalpindi
CO values are identical (same grid cell); from 2024-10-26 they differ, which suggests
Open-Meteo began serving CO from a different, finer-resolution source (its docs list
a 0.1 deg CAMS global greenhouse-gas forecast from late 2024). This is an inference,
not documented by the source; treat ``co_ugm3`` as possibly inconsistent across that date.
- *Hourly series are interpolated* by Open-Meteo from 3-hourly model output, so the
"daily max" is a smoothed maximum.
- *Correlated pollutants.* CO, NO2 and SO2 come from the same model and share emission
and meteorology drivers with PM2.5. They are legitimate features (not functions of the
target), but a model using them is "predicting a model output from other outputs of
the same model". For a purely meteorological task, drop them (see tasks).
- Weather comes from a different grid (ERA5 ~0.25 deg / ERA5-Land ~0.1 deg) than air
quality, so the two can describe slightly different areas.
- Ten large cities only; no rural or smaller-town coverage.
*numpy output.* ``city`` and ``province`` are categorical, so
``load_pak_air_quality(as_frame=False)`` returns ``X`` as a numpy **object** array
(the same thing scikit-learn's loaders do with mixed types). Use ``as_frame=True``
(the "auto" default already does this) and one-hot encode, or drop the two columns.
Sanity check (2026-11-29, 40 rows with a missing target dropped, one-hot city/province,
median imputation): RandomForest trained on 2022-2024 and tested on 2025 gives
R^2 ~ 0.83 (LinearRegression ~ 0.75); weather + calendar + location only (no other
pollutants) gives R^2 ~ 0.73. A random split gives ~0.95, inflated by the Islamabad/Rawalpindi duplication.
**Suggested tasks:**
1. *Regression (beginner):* predict daily mean PM2.5 from weather, calendar and city
features; compare LinearRegression with RandomForest using a 2025 hold-out year.
2. *Classification (beginner):* bin ``pm2_5_ugm3`` into Pakistan NEQS / WHO-style bands
(e.g. > 35 ug/m3 = unhealthy, NEQS 24-h limit for PM2.5) and predict the band.
3. *Time series (intermediate):* forecast tomorrow's Lahore PM2.5 from lagged PM2.5 and
weather; study the November-January smog season and the role of low boundary layer
height and low wind speed.
4. *Clustering / EDA:* cluster cities by their seasonal pollutant profiles (Quetta and
Karachi vs the Punjab plain); explore dust events (``dust_ugm3``) in Sindh and
Balochistan.
**Citation / attribution:**
Generated using Copernicus Atmosphere Monitoring Service (CAMS) information [2022-2025]
(CAMS global
atmospheric composition forecasts, ECMWF), retrieved via the Open-Meteo Air Quality API.
Weather: Hersbach, H. et al. (2018/2023): ERA5 hourly data on single levels from 1940 to
present, Copernicus Climate Change Service (C3S) Climate Data Store,
doi:10.24381/cds.adbb2d47; Munoz Sabater, J. (2019): ERA5-Land hourly data from 1950 to
present, C3S CDS, doi:10.24381/cds.e2161bac; retrieved via the Open-Meteo Historical
Weather API. Coordinates: GeoNames (CC BY 4.0) via the Open-Meteo Geocoding API.
Zippenfenig, P. (2023). Open-Meteo.com Weather API [Computer software]. Zenodo.
https://doi.org/10.5281/ZENODO.7970649. Weather data by Open-Meteo.com
(https://open-meteo.com/), licensed CC BY 4.0
(https://creativecommons.org/licenses/by/4.0/). Changes: hourly values aggregated to daily
means/max and joined by pakdata. Neither the European Commission, ECMWF nor Open-Meteo is
responsible for any use of this data.
Citation and attribution
Air quality: Generated using Copernicus Atmosphere Monitoring Service (CAMS) information [2022-2025] (CAMS global atmospheric composition forecasts, ECMWF), retrieved via the Open-Meteo Air Quality API. Weather: Hersbach, H. et al. (2018/2023): ERA5 hourly data on single levels from 1940 to present, Copernicus Climate Change Service (C3S) Climate Data Store, doi:10.24381/cds.adbb2d47; Munoz Sabater, J. (2019): ERA5-Land hourly data from 1950 to present, C3S CDS, doi:10.24381/cds.e2161bac; retrieved via the Open-Meteo Historical Weather API. Coordinates: GeoNames (CC BY 4.0) via Open-Meteo Geocoding API. Zippenfenig, P. (2023). Open-Meteo.com Weather API [Computer software]. Zenodo. https://doi.org/10.5281/ZENODO.7970649. Weather data by Open-Meteo.com (https://open-meteo.com/), licensed CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Changes: hourly values aggregated to daily means/max and joined by pakdata. Neither the European Commission, ECMWF nor Open-Meteo is responsible for any use of this data.
Packaged by pakdata (https://github.com/junaidaslam2006/pakData). Build script: scripts/build_pak_air_quality.py.