How guttof/pyzdc works
Purpose and public entry point
PyZDC is a Python 3.11+ library for retrieving and analyzing Brazilian Aedes aegypti epidemiological data, including Dengue, Zika, and Chikungunya. Consumers import the package as pyzdc; its exported API is rooted at pyzdc/__init__.py and provides processed tables as pandas DataFrames.
Pipeline architecture
The repository is organized as an ETL-style data pipeline:
1. extract raw disease/year data,
2. transform database-oriented and column-level representations,
3. infer schemas,
4. load or refresh accessible datasets,
5. expose domain-specific query functions.
The stage boundaries are explicit package directories: pyzdc/extract/, pyzdc/transform/, pyzdc/infer_schema/, and pyzdc/load/.
Extraction boundary
Raw retrieval is centralized in pyzdc/extract/get_raw.py. This is the external-data boundary: disease and year inputs are converted into raw source data before local transformations. Downstream code should avoid coupling directly to source formats and use this module’s output contract.
Transformation and validation
DuckDB is the material transformation runtime, used for validation and processing of epidemiological tables. pyzdc/transform/transform_db.py handles database-level transformations, while pyzdc/transform/transform_columns.py normalizes or maps columns. These stages bridge inconsistent source fields to the package’s consumer-facing tabular schema.
Schema contract
Schema inference and model definitions establish the structural contract between transformed data and access functions. pyzdc/infer_schema/infer_schema.py derives schemas from data; pyzdc/schemas/model_schema.py and pyzdc/schemas/model_schema_pydantic.py define model representations, with Pydantic providing runtime validation where used. Changes to extraction or transformations should be reconciled here to preserve API stability.
Loading and query-facing access
pyzdc/load/refresh_data.py refreshes prepared data, and pyzdc/load/show_data.py reads or presents it. pyzdc/get_info/get_info.py is the domain-facing access layer for tables such as notifications, personal data, and clinical signs. The primary control flow is: public API → info/query functions → prepared DuckDB-backed data; refresh paths invoke extraction, transformation, and schema work.
Reference data and shared infrastructure
Static reference mappings are packaged under pyzdc/data/json/, notably cities.json, states.json, and columns_translated_english.json. They support geographic interpretation and column translation rather than requiring an external reference service. Shared database and operational concerns are isolated in pyzdc/utils/db_utils.py, pyzdc/utils/config.py, and pyzdc/utils/logger.py.
Delivery and quality boundaries
The package is distributed as a Python library, with dependencies and runtime metadata in pyproject.toml and requirements.txt. GitHub Actions CI is defined in .github/workflows/ci.yaml; documentation is published through MkDocs/Read the Docs configuration (mkdocs.yml, .readthedocs.yaml).
Main entry points: refresh_data.py Dataset refresh · infer_schema.py Schema inference · transform_db.py Database transforms · transform_columns.py Column normalization
Components 19
Data Pipeline
ETL stages that prepare epidemiological tables.
- Disease source data · Raw Dengue, Zika, and Chikungunya data by year.
- Raw extraction · Converts disease and year inputs into a raw-data contract.
pyzdc/extract/get_raw.py - Database transforms · Validates and processes epidemiological tables.
pyzdc/transform/transform_db.py - Column normalization · Normalizes and maps inconsistent source columns.
pyzdc/transform/transform_columns.py - Schema inference · Derives schemas from transformed data.
pyzdc/infer_schema/infer_schema.py - Dataset refresh · Orchestrates preparation and refresh of accessible data.
pyzdc/load/refresh_data.py - Prepared-data reader · Reads or presents prepared datasets.
pyzdc/load/show_data.py
Contracts & Reference Data
Schema definitions and packaged mappings.
- Model schema · Defines structural model representations.
pyzdc/schemas/model_schema.py - Pydantic schema · Validates model representations where used.
pyzdc/schemas/model_schema_pydantic.py - Reference mappings · City, state, and English-column mappings.
pyzdc/data/json/columns_translated_english.json
Public Access
Consumer-facing package and query layer.
- pyzdc public API · Exports DataFrame-oriented library functions.
pyzdc/__init__.py - Domain queries · Provides notifications, personal-data, and clinical-sign tables.
pyzdc/get_info/get_info.py - Prepared datasets · Accessible epidemiological tables used by queries.
Shared Infrastructure
Database and operational support.
- Database utilities · Shared database concerns.
pyzdc/utils/db_utils.py - Runtime configuration · Operational configuration.
pyzdc/utils/config.py - Logging · Shared operational logging.
pyzdc/utils/logger.py
Delivery
Packaging, CI, and documentation.
- Package metadata · Python dependencies and runtime metadata.
pyproject.toml - GitHub Actions CI · Automated quality boundary.
.github/workflows/ci.yaml - MkDocs documentation · Published documentation configuration.
mkdocs.yml
Connections 19
- pyzdc public API → Domain queries: exposes
- Domain queries → Prepared datasets: queries
- Prepared-data reader → Prepared datasets: reads
- Disease source data → Raw extraction: retrieved by
- Raw extraction → Database transforms: raw data
- Database transforms → Column normalization: processed tables
- Column normalization → Schema inference: normalized data
- Schema inference → Dataset refresh: schema contract
- Dataset refresh → Prepared datasets: refreshes
- Model schema → Schema inference: defines models
- Pydantic schema → Schema inference: validates
- Reference mappings → Column normalization: translation mappings
- Database utilities → Database transforms: database support
- Database utilities → Dataset refresh: database support
- Runtime configuration → Dataset refresh: configures
- Logging → Dataset refresh: logs
- Package metadata → pyzdc public API: packages
- GitHub Actions CI → Package metadata: validates
- MkDocs documentation → pyzdc public API: documents