← pakdata
Daily weather (ERA5 reanalysis) for 16 Pakistani cities, 2016-2025
58,448 rowstarget: temp_max_c
CC BY 4.0snapshot 2026.11
Source: Open-Meteo Historical Weather API (ERA5 reanalysis, Copernicus C3S / ECMWF)
Get it: pakdata (Python) · Hugging Face · Kaggle · CSV
Load it
pip install pakdata
from pakdata import load_pak_weather
X, y = load_pak_weather(return_X_y=True)
More ways (pandas, Polars, DuckDB, PyTorch, R, Excel, JavaScript): usage guide.
Data card
.. _pak_weather_dataset:
Daily weather (ERA5 reanalysis) for 16 Pakistani cities, 2016-2025
------------------------------------------------------------------
**Data Set Characteristics:**
:Number of Instances: 58,448 (16 cities x 3,653 days), no missing values
:Number of Attributes: 19 features (incl. ``city`` and ``province`` as categories) + target;
27 columns in ``frame``
:Default target: ``temp_max_c`` (daily maximum 2 m air temperature, degrees C)
:Time coverage: 2016-01-01 to 2025-12-31, daily; days are local calendar days (Asia/Karachi, UTC+5)
:Geographic coverage: 16 cities covering every province and territory: Punjab (Lahore,
Rawalpindi, Faisalabad, Multan, Sialkot), Sindh (Karachi, Hyderabad, Sukkur), Khyber
Pakhtunkhwa (Peshawar, Dera Ismail Khan), Balochistan (Quetta, Gwadar), Islamabad Capital
Territory (Islamabad), Gilgit-Baltistan (Gilgit, Skardu), Azad Jammu and Kashmir (Muzaffarabad)
:Source: Open-Meteo Historical Weather API, ERA5 model (``models=era5``),
https://archive-api.open-meteo.com/v1/archive ; docs https://open-meteo.com/en/docs/historical-weather-api.
ERA5 is produced by the Copernicus Climate Change Service (C3S) at ECMWF.
:License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/), as stated at
https://open-meteo.com/en/licence ; attribution required (see below)
:Snapshot: 2026.11 (retrieved 2026-11-29)
**Columns:**
- ``date`` (date): local calendar day. Excluded from features.
- ``city`` (category): city name.
- ``province`` (category): province / territory of the city.
- ``latitude``, ``longitude`` (decimal degrees): city-centre point that was requested.
- ``grid_latitude``, ``grid_longitude`` (decimal degrees): centre of the ERA5 0.25 degree grid cell
Open-Meteo actually used. Excluded from features (duplicates latitude/longitude).
- ``elevation_m`` (m): terrain elevation of the requested point as reported by Open-Meteo
(from its 90 m digital elevation model); used by Open-Meteo to adjust temperature.
- ``year``, ``month``, ``day_of_year`` (integers): parts of ``date``.
- ``temp_max_c`` (degrees C): daily maximum 2 m temperature. **Default target.**
- ``temp_min_c`` (degrees C): daily minimum 2 m temperature. Excluded from features (near-leak).
- ``temp_mean_c`` (degrees C): daily mean 2 m temperature. Excluded from features (near-leak).
- ``apparent_temp_max_c`` (degrees C): daily maximum "feels-like" temperature, computed from
temperature, humidity and wind. Excluded from features (direct function of temperature).
- ``precip_mm`` (mm): daily total precipitation (rain + snow water equivalent).
- ``rain_mm`` (mm): daily rain only.
- ``precip_hours_h`` (hours): number of hours in the day with precipitation.
- ``wind_speed_max_kmh`` (km/h): maximum 10 m wind speed.
- ``wind_gusts_max_kmh`` (km/h): maximum 10 m wind gust.
- ``wind_dir_dominant_deg`` (degrees, 0-360, from north): dominant 10 m wind direction.
- ``shortwave_radiation_mj_m2`` (MJ/m2): daily sum of incoming shortwave (solar) radiation.
- ``sunshine_duration_h`` (hours): sunshine duration (converted from the API's seconds; Open-Meteo
derives it from direct radiation exceeding 120 W/m2).
- ``cloud_cover_mean_pct`` (%): mean total cloud cover.
- ``rel_humidity_mean_pct`` (%): mean 2 m relative humidity (daily aggregate provided by the API).
- ``surface_pressure_mean_hpa`` (hPa): mean surface pressure (strongly tied to elevation).
- ``et0_mm`` (mm): FAO-56 Penman-Monteith reference evapotranspiration. Excluded from features,
because FAO-56 computes it directly from Tmax/Tmin (including it raised a random-forest R^2
from 0.947 to 0.977 in our check).
**How it was built:** ``scripts/build_pak_weather.py`` sends one request per city to the
Open-Meteo archive endpoint with ``models=era5``, ``timezone=Asia/Karachi`` and the 16 daily
variables above, for 2016-01-01 to 2025-12-31. Responses are renamed to snake_case with units,
``sunshine_duration`` is divided by 3600 (and rounded to 2 decimals), and city, province,
requested coordinates, grid-cell coordinates, elevation and date parts are added. Rows are sorted
by ``city`` then ``date``. No values were filled, interpolated or altered otherwise. The source
returned no missing values for these cities and dates.
*Combining pak_weather and pak_air_quality:* both have weather columns with the same
names (``temp_max_c``, ``precip_mm`` ...), but they come from different grid cells and
city coordinates, so the values differ. When you merge them on ``date`` and ``city``,
keep the weather from pak_weather (or add suffixes) instead of mixing the two.
**Caveats and known biases:**
- This is **reanalysis (model) data, not station measurements**. ERA5 has a ~0.25 degree (~25-30
km) grid, so each value is a grid-cell estimate near the city, not a reading from the city's
PMD observatory. Urban heat island effects are not captured.
- **Mountain cities are the least accurate.** For Gilgit and Skardu the grid cell is dominated
by high mountain terrain: ERA5 gives about 1,100-1,200 mm/year precipitation and a mean
``temp_max_c`` of 16.4 (Gilgit) and 11.4 (Skardu) degrees C. Valley stations
record far less rain (a few hundred mm or less) and warmer days. Muzaffarabad has the same
problem to a smaller degree. Treat these rows as "the surrounding mountain cell", not the town.
- ERA5 smooths extremes: single-day rainfall peaks (e.g. Karachi urban flooding) and the hottest
heatwave readings at stations are usually higher than the values here.
- Neighbouring cities can fall in adjacent or near-identical grid cells (e.g. Islamabad 33.75 N
and Rawalpindi 33.5 N), so their series are highly correlated. Use grouped/city-wise or
time-based splits to avoid an over-optimistic evaluation.
- The most recent days of ERA5 are first released as a preliminary product (ERA5T) and can be
revised slightly. The values here are as served on 2026-11-29.
- Rows are a time series per city: a random train/test split leaks information between
neighbouring days. Prefer splitting by year (e.g. train 2016-2023, test 2024-2025).
- Sanity check (train 2016-2023, test 2024-2025, one-hot city/province, default features):
LinearRegression R^2 = 0.81 (MAE 3.1 degrees C); RandomForestRegressor R^2 = 0.95 (MAE 1.7 degrees C).
**Suggested tasks:**
1. Regression (beginner): predict ``temp_max_c`` from season, location, radiation, humidity,
cloud and wind. Compare linear regression with a random forest using a year-based split.
2. Classification (beginner/intermediate): make a binary "rainy day" label
(``precip_mm >= 1``) and predict it from humidity, cloud cover, pressure and season. Remove
``rain_mm`` and ``precip_hours_h`` from the features first, because they leak this label.
3. Time-series forecasting (intermediate): forecast tomorrow's ``temp_max_c`` for Lahore or Karachi
from lagged values. Compare against a "same as yesterday" baseline.
4. Clustering (intermediate): aggregate monthly climatologies per city and cluster the 16 cities
into climate zones (coastal, plains, plateau, mountain).
**Citation / attribution:**
Weather data by Open-Meteo.com (https://open-meteo.com/), licensed under CC BY 4.0
(https://creativecommons.org/licenses/by/4.0/).
Zippenfenig, P. (2023). Open-Meteo.com Weather API [Computer software]. Zenodo.
https://doi.org/10.5281/ZENODO.7970649
Underlying data: Hersbach, H., Bell, B., Berrisford, P., et al. (2023). ERA5 hourly data on single
levels from 1940 to present. Copernicus Climate Change Service (C3S) Climate Data Store (CDS).
https://doi.org/10.24381/cds.adbb2d47 . Contains modified Copernicus Climate Change Service
information 2026.
Changes made by pakdata: selected cities and variables, renamed columns, converted sunshine
duration from seconds to hours, added date parts and province labels.
Cite
Weather data by Open-Meteo.com (https://open-meteo.com/), licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Zippenfenig, P. (2023). Open-Meteo.com Weather API [Computer software]. Zenodo. https://doi.org/10.5281/ZENODO.7970649. Underlying data: Hersbach, H., Bell, B., Berrisford, P., et al. (2023). ERA5 hourly data on single levels from 1940 to present. Copernicus Climate Change Service (C3S) Climate Data Store (CDS). https://doi.org/10.24381/cds.adbb2d47. Contains modified Copernicus Climate Change Service information 2026. Changes: selected cities/variables, renamed columns, sunshine duration converted from seconds to hours, added date parts and province labels.
Packaged by pakdata, DOI 10.5281/zenodo.24662545.