Skip to main content

pycensuskr

Binder PyPI Downloads

A Python package for Korean district-level census and geographic data.

Installation

PyPI

pip install pycensuskr

From source

git clone https://github.com/sigmafelix/pycensuskr.git
cd pycensuskr
pip install -e .

# python setup.py install

For development

git clone https://github.com/sigmafelix/pycensuskr.git
cd pycensuskr
pip install -e ".[dev]"

Usage

from pycensuskr import CensusKR
from matplotlib import pyplot as plt
import geopandas as gpd

# Create a CensusData instance
census = CensusKR()

# load specific year data
data_2020 = census.load_data(year = 2020)
print(data_2020)

# load district boundaries for a specific year
districts_2020 = census.load_districts(year = 2020)
districts_2020["adm2_re"] = districts_2020["adm2_code"].astype(str).str.slice(0,4)
# aggregate geometries by adm2_re
districts_2020 = districts_2020.dissolve(by="adm2_re", as_index=False)
districts_2020["adm2_code"] = districts_2020["adm2_re"] + "0"
districts_2020["adm2_code"] = districts_2020["adm2_code"].astype(int)

# cleaned data with variable types
df_tax_2020 = census.anycensus(year = 2020, type = "tax", aggregator = "sum")

districts_tax_2020 = districts_2020.merge(df_tax_2020, on="adm2_code")
print(districts_tax_2020)

districts_tax_2020.plot("income_labor_mil")
plt.show()

Filter non-/autonomous district codes

from pycensuskr import CensusKR

# Create a CensusData instance
census = CensusKR()

# load population data
pop20 = census.anycensus(year=2020, type="population")
pop20_nonauto = census.detect_adm2_type(df=pop20, mode="non")

Load 2020 adm3-level data

  • From version 0.3.0, users can load adm3 (Eup/Myeon/Dong) level data and boundaries. To note, adm3 level data is currently available for population, housing, mortality, and economy types in 2020.
from pycensuskr import CensusKR

# Create a CensusData instance
census = CensusKR()

# load population data
pop20_adm3 = census.anycensus(year = 2020, type = "population", level = "adm3")

# load housing data
housing20_adm3 = census.anycensus(year = 2020, type = "housing", level = "adm3")

Notes on data updates

Our data cleaning and processing pipeline is based on the original R package tidycensuskr. We periodically synchronize the bundled datasets used in this package with those in R tidycensuskr and tidycensuskr.sf to ensure accuracy and relevance. Please refer to the tidycensuskr webpage for details on the latest data updates and changes.

Data license disclaimer

{style="fig-align: center; width: 200px;"}

Development

Running tests

pytest

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for pycensuskr 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycensuskr 0.3.0
File Size Uploaded
pycensuskr-0.3.0.tar.gz 34.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycensuskr 0.3.0
File Interpreter ABI Platform
pycensuskr-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 68.2 MB

Release files / pycensuskr-0.3.0.tar.gz

Download URL pycensuskr-0.3.0.tar.gz
Size 34.1 MB
Tags Source
SHA-256 checksum
How to use checksums
7223872b201e73eba2fc959adf4d488673f56796564f25209e80ef239ef7dad8
BLAKE2b-256 checksum
How to use checksums
56c68f2aeddb14ec312555df7ecb88f41631ec52b98e3a5add16ffeb0135317c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.

Transparency log

Release files / pycensuskr-0.3.0-py3-none-any.whl

Download URL pycensuskr-0.3.0-py3-none-any.whl
Size 34.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
1678516f1d319656b6250c64a44c4401f8ef39ab9de8ec5096143dd9f4994666
BLAKE2b-256 checksum
How to use checksums
461e68dbc548339a3d9532cd028a1ecbb21f8d0a35f4d7c47bf2584d1478ec36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.3

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page