Skip to main content

A Python package for Korean census data processing

Project description

pycensuskr

A Python package template for Korean census data processing.

Installation

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 __version__
from pycensuskr import CensusKR
from matplotlib import pyplot as plt
import geopandas as gpd

# Print version
print(__version__)

# Create a CensusData instance
census = CensusKR()

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

# load district boundaries for a specific year
districts_2020 = census.load_districts(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.1.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

pycensuskr-0.1.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pycensuskr-0.1.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pycensuskr-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c3de469f8b180c2babe7609ade0634f06109a22fa268e8f98d7adf35dcc726ce
MD5 fd8cc8c4f504861cf90a40566781bfd8
BLAKE2b-256 c61594644b07ecf70c9cc22302c82491f4e8a6d35208be4849ba82c799a0b582

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycensuskr-0.1.1.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.1.1-py3-none-any.whl.

File metadata

  • Download URL: pycensuskr-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pycensuskr-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c4286dd72855435b2380ba08d12ddeed88f74dbf40af05501319d6f47e76bcc6
MD5 db5df23db4be3d13655e751c0ee342b3
BLAKE2b-256 5adf7ee39e96aa0854f0e6e12db6be87fef31be7ab0e932a0e461284c0dadb56

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycensuskr-0.1.1-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