pycancensus: Canadian Census Data in Python

pycancensus provides a Python interface to access Canadian Census data and geographies, offering a Python equivalent to the R cancensus package.

Key Features

  • Access to Canadian Census data through Statistics Canada’s API

  • Geographic data integration with Census boundaries

  • Data caching for improved performance

  • Compatible with pandas and geopandas workflows

  • Command-line interface for quick data access

Quick Start

Install pycancensus from GitHub (not yet on PyPI):

pip install git+https://github.com/dshkol/pycancensus.git

Get started with basic census data:

import pycancensus as pycan

# Set your API key
pycan.set_api_key("your_api_key_here")

# Get census data
data = pycan.get_census(
    dataset="CA21",
    regions={"CMA": "59933"},  # Vancouver CMA
    vectors=["v_CA21_1"]       # Population
)

Installation

Note: pycancensus is not yet published on PyPI. Install directly from GitHub:

# Install latest version
pip install git+https://github.com/dshkol/pycancensus.git

Coming soon: Publication to PyPI for pip install pycancensus

For development:

git clone https://github.com/dshkol/pycancensus
cd pycancensus
pip install -e .[dev,docs]

Contributing

Contributions are welcome! Please see our GitHub repository for more information.

Indices and tables