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 adm3-level data

  • ADM3 (Eup/Myeon/Dong) boundaries are available for 2010, 2015, and 2020. ADM3 population and housing data is available for 2015, 2020, and 2025; economy and mortality ADM3 data is available for 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")

# load 2025 neighborhood-level housing data (tabular; no 2025 boundaries are bundled)
housing25_adm3 = census.anycensus(year = 2025, 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.4.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.4.0
File Size Uploaded Provenance Actions
pycensuskr-0.4.0.tar.gz 36.4 MB With provenance Details for pycensuskr-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 72.9 MB

Release files / pycensuskr-0.4.0.tar.gz

Download URL pycensuskr-0.4.0.tar.gz
Size 36.4 MB
Tags Source
SHA-256 checksum
How to use checksums
10d785f44718c541cdc31075622504b19d0de95d2bf35fd2c7e3b5cf232b19f9
BLAKE2b-256 checksum
How to use checksums
bfa4eb6e5216a591285bfcd9124b170569f124480f6a39911bec262814eb41c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 24, 2026.

Transparency log

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

Download URL pycensuskr-0.4.0-py3-none-any.whl
Size 36.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
481c0110aa8090f7ee626537c48029620bedb3780f0374b0a557967291014dd0
BLAKE2b-256 checksum
How to use checksums
d6bfee76a1d86649fa8638512f4e20eea4a8119fb13ed4226c4c6226c8922c1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 24, 2026.

Transparency log

Security for pycensuskr 0.4.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pycensuskr-0.4.0.tar.gz

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 Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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