← pakdata
Pakistan Census 2023 (7th Population and Housing Census): 136 districts, population, literacy, housing
136 rowstarget: literacy_rate_pct
PBS open government licence (Tier 1 Open Aggregate, reuse with attribution)snapshot 2026.11
Source: Pakistan Bureau of Statistics (7th Population and Housing Census 2023, district results; census23.pbos.gov.pk)
Get it: pakdata (Python) · Hugging Face · Kaggle · CSV
Load it
pip install pakdata
from pakdata import load_pak_census_districts
X, y = load_pak_census_districts(return_X_y=True)
More ways (pandas, Polars, DuckDB, PyTorch, R, Excel, JavaScript): usage guide.
Data card
.. _pak_census_districts_dataset:
Pakistan Census 2023: district results (population, literacy, housing)
-----------------------------------------------------------------------
**Data Set Characteristics:**
:Number of Instances: 136 (every district enumerated in the 2023 census: Punjab 36,
Sindh 30, Khyber Pakhtunkhwa 35, Balochistan 34, Islamabad Capital Territory 1)
:Number of Attributes: 29 features + target (34 columns in ``frame``; ``district_code``,
``district``, ``literacy_rate_male_pct`` and ``literacy_rate_female_pct`` are kept in
the frame but not used as features)
:Default target: ``literacy_rate_pct`` (% of population aged 10 and above that is literate)
:Time coverage: census reference period 2023 (enumeration March-May 2023); 2017 census
population for comparison
:Geographic coverage: Pakistan's four provinces and Islamabad Capital Territory, district
level (2023 administrative boundaries). Azad Jammu & Kashmir and Gilgit-Baltistan were
not part of the 2023 census results and are not included.
:Source: Pakistan Bureau of Statistics (PBS), 7th Population and Housing Census 2023
("The Digital Census"). District-wise tables: https://www.pbs.gov.pk/census/ ;
machine-readable district aggregates from the official PBS results portal
https://census23.pbos.gov.pk/Analysis/DistrictWise
:License: PBS standard open government licence for Tier 1 "Open Aggregate" products
(tables, indicators, publications, non-confidential APIs), "permitting copying,
adaptation and commercial/non-commercial reuse with attribution", per the PBS
Pakistan Official Statistics & Data Dissemination Policy,
https://www.pbs.gov.pk/data-dissemination/ (read 2026-11-29). (The PBS website
footer also carries a generic "All Rights Reserved" notice; the dissemination policy
is the specific grant for statistical tables and is what this dataset relies on.)
:Snapshot: 2026.11 (retrieved 2026-11-29)
**Columns:**
- ``district_code`` (int): PBS district code used by the census portal (identifier, excluded)
- ``province`` (category): Punjab, Sindh, Khyber Pakhtunkhwa, Balochistan, Islamabad Capital Territory
- ``division`` (category): administrative division, 31 levels (Islamabad is "Federal Capital Area")
- ``district`` (str): district name, title-cased from PBS spelling (identifier, excluded)
- ``area_sq_km`` (km^2): district area as printed in PBS Table 1
- ``population_2023`` (persons): total population, PBS Table 1 "All sexes"
- ``male``, ``female``, ``transgender`` (persons): population by sex (Table 1)
- ``urban_population``, ``rural_population`` (persons): population by area type
- ``urban_pct`` (%): urban_population / population_2023 x 100 (Table 1 "urban proportion")
- ``sex_ratio_males_per_100_females``: male / female x 100 (Table 1)
- ``households`` (count): number of households (regular + collective + homeless)
- ``avg_household_size`` (persons): population_2023 / households, 2 decimals (see caveats)
- ``population_density_per_sq_km`` (persons/km^2): population_2023 / area_sq_km (Table 1)
- ``population_2017`` (persons): 2017 census population on 2023 district boundaries (Table 1)
- ``annual_growth_rate_pct`` (%/year): PBS 2017-2023 average annual growth rate (Table 1)
- ``literacy_rate_pct`` (%): literate persons aged 10+ / population aged 10+ (Table 12) **target**
- ``literacy_rate_male_pct`` (%): male literacy 10+ (see caveats; excluded, part of target)
- ``literacy_rate_female_pct`` (%): female literacy 10+ (Table 12; excluded, part of target)
- ``out_of_school_5_16_pct`` (%): out-of-school children aged 5-16 / population aged 5-16
- ``disability_pct`` (%): persons reporting any functional difficulty (Washington Group
questions, any degree incl. "some difficulty") / persons with a disability response
- ``age_0_14_pct``, ``age_65_plus_pct`` (%): share of the detailed-record population in those age groups
- ``hh_pacca_house_pct`` (%): housing units with pacca (fired brick / concrete) structure
- ``hh_electricity_pct`` (%): households using electricity as main source of lighting
- ``hh_gas_pct`` (%): households using piped natural gas as cooking fuel
- ``hh_internet_pct``, ``hh_mobile_pct``, ``hh_tv_pct`` (%): households with internet / mobile phone / television
- ``hh_drinking_water_inside_pct`` (%): households whose drinking-water source is inside the dwelling
- ``hh_no_toilet_pct`` (%): households with no toilet facility
- ``hh_member_abroad_pct`` (%): households with at least one member living abroad
**How it was built:** ``scripts/build_pak_census_districts.py`` lists the 136 district codes
from the PBS census portal (``/Misc/GetDropDownDataComp/``, Level=3) and fetches each
district's aggregate record from ``/Analysis/GetPopulation/`` (the JSON the portal's own
"District Wise" page uses), two districts per request with 1 s pauses. Headline columns use
the portal's headcount fields, which are the figures printed in PBS Table 1; all percentages,
ratios and densities are computed by pakdata from the published counts and rounded to 2
decimals. No value is imputed and there are no missing values. Rows are sorted by province,
division, district.
Verification against the official PBS PDF tables (https://www.pbs.gov.pk/census/):
- Table 1 (all five province/ICT district PDFs): for 125 districts compared automatically,
area, population, male, female, transgender, sex ratio, density, urban proportion, 2017
population and annual growth rate match the printed values exactly (to the printed
precision); the other 11 (names wrapped across lines in the PDF) were checked by hand on
the printed figures and also match.
- Table 12: total literacy (10+) matches for all 134 districts parsed from the PDFs
(2 could not be parsed automatically, not mismatched); female literacy matches for all 134.
- Totals: the 136 districts sum to 241,499,431, exactly the PBS national 2023 total
(four provinces + ICT); Punjab 127,688,922, Sindh 55,696,147, KP 40,856,097,
Balochistan 14,894,402, ICT 2,363,863.
**Caveats and known biases:**
- Two population bases. Headcount columns (``population_2023`` ... ``households``) are the
official Table 1 totals. Literacy, age, disability and household-amenity shares come from
the detailed census records, whose population is slightly smaller (e.g. Lahore
12,978,661 vs 13,004,135); shares are therefore not exactly "share of population_2023".
- ``avg_household_size`` is computed at full precision; PBS Table 1 prints one decimal using
a slightly different rounding/denominator, so about half the districts differ from the
printed figure by 0.1.
- ``literacy_rate_male_pct``: the portal's "male" literacy counts include transgender
persons, so it can differ from the male column of Table 12 by up to ~0.03 percentage points
(7 of 134 districts). Total and female literacy match Table 12 exactly.
- ``hh_*`` amenity shares use slightly different denominators (households for lighting, gas
and members abroad; housing units for pacca structure; households answering each item for
internet/mobile/TV/water/toilet).
- The 2017 population and growth rates are as re-tabulated by PBS on 2023 boundaries.
Several districts were created after 2017; growth rates in Balochistan and the merged
former-FATA districts are known to be affected by 2017 under-coverage and should be
interpreted with care. Census results in some districts have been publicly disputed.
- With only 136 rows, use cross-validation and keep models simple. Rows are spatially
correlated (neighbouring districts in the same division are similar); grouped CV by
``division`` or ``province`` gives a more honest error estimate.
- ``out_of_school_5_16_pct`` is strongly (inversely) related to literacy; it is a different
quantity and is kept as a feature, but dropping it is a good exercise (5-fold R^2 for a
random forest falls from ~0.92 to ~0.89).
- If you choose ``target="annual_growth_rate_pct"``, drop ``population_2017`` together with
the 2023 population counts yourself: the growth rate is a direct function of the two
populations. Without them, growth is very hard to predict (R^2 near 0), which is itself a
lesson about census data quality.
**Suggested tasks:**
1. Regression (beginner): predict ``literacy_rate_pct`` from housing and amenity indicators
with linear regression; compare with a random forest using 5-fold CV (R^2 around 0.9).
2. Feature importance / fairness (intermediate): predict ``literacy_rate_female_pct`` (as
``target``) and study which features drive the gender literacy gap; use GroupKFold by
``province`` to test generalisation to an unseen province.
3. Clustering (intermediate): standardise the ``*_pct`` columns and cluster districts with
k-means or hierarchical clustering; compare clusters with provinces on a table or map.
4. Classification: label districts as majority-urban (``urban_pct`` > 50) and predict it
from household amenities, excluding the urban/rural population columns.
**Citation / attribution:** Pakistan Bureau of Statistics (PBS), 7th Population and Housing
Census 2023 ("The Digital Census"), district-level results, https://www.pbs.gov.pk/census/
and https://census23.pbos.gov.pk/Analysis/DistrictWise, retrieved 2026-11-29. Reused under
the PBS Pakistan Official Statistics & Data Dissemination Policy
(https://www.pbs.gov.pk/data-dissemination/), Tier 1 open aggregate statistics, open
government licence permitting reuse with attribution. Modified by pakdata: district names
title-cased; percentages, ratios and densities computed from the published counts.
Cite
Pakistan Bureau of Statistics (PBS), 7th Population and Housing Census 2023 ('The Digital Census'), district-level results, https://www.pbs.gov.pk/census/ and https://census23.pbos.gov.pk/Analysis/DistrictWise, retrieved 2026-11-29. Reused under the PBS Pakistan Official Statistics & Data Dissemination Policy (https://www.pbs.gov.pk/data-dissemination/): Tier 1 open aggregate statistics carry a standard open government licence permitting copying, adaptation and commercial/non-commercial reuse with attribution. Modified by pakdata: district names title-cased, percentages, ratios and densities computed from the published counts.
Packaged by pakdata, DOI 10.5281/zenodo.24662545.