Skip to main content

A Python package for Korean census data processing

Project description

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()

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 tidycensussfkr to ensure accuracy and relevance. Please refer to the tidycensuskr webpage for details on the latest data updates and changes.

Development

Running tests

pytest

License

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycensuskr-0.2.8.tar.gz (9.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycensuskr-0.2.8-py3-none-any.whl (9.8 MB view details)

Uploaded Python 3

File details

Details for the file pycensuskr-0.2.8.tar.gz.

File metadata

  • Download URL: pycensuskr-0.2.8.tar.gz
  • Upload date:
  • Size: 9.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pycensuskr-0.2.8.tar.gz
Algorithm Hash digest
SHA256 37c075be9991cff749fc81dbbd9b3b0af45db672749f67d4b7e3956c6bfc8cf4
MD5 20a6a64e0d30f4dcbbd46bd20a852ba5
BLAKE2b-256 b8873837d659c24233e768be9a7ed32ae559e01385c60708f4fcff29fdb8dbfd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycensuskr-0.2.8.tar.gz:

Publisher: build-and-release.yml on sigmafelix/pycensuskr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycensuskr-0.2.8-py3-none-any.whl.

File metadata

  • Download URL: pycensuskr-0.2.8-py3-none-any.whl
  • Upload date:
  • Size: 9.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pycensuskr-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 e2ce910bcf15ffd8e05bd4f999723817fbde8b8b8977019b93e978c9d58f7cff
MD5 0862c8312f6bd22b5ac5362d572addf6
BLAKE2b-256 6a91202221c9eb5d917ba7b7390b35f70f2128fca442dc2304b13fbbdd54e4f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycensuskr-0.2.8-py3-none-any.whl:

Publisher: build-and-release.yml on sigmafelix/pycensuskr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page