spb/wp9_uqo Public
UQO Working Paper No. 9 — A grand hedonic model of the Canadian housing market: decomposing structure and location value.
TeX 60.1%
Python 39.8%
1#!/usr/bin/env python32# Author: Simon-Pierre Boucher — contact@spboucher.ai3"""Step 01 — Build the estimation sample.45Reads the raw DuckDB snapshot (``data/raw/realtor_mls_unique.duckdb``),6parses the semi-structured fields, applies the sample restrictions and trims,7and writes ``data/processed/analysis.parquet``.89Usage: python scripts/01_build_sample.py10"""11import sys12from pathlib import Path1314sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))1516from wp9 import sample # noqa: E402171819def main() -> None:20 s = sample.build_and_save()21 by_cat = s.groupby("cat").size().to_dict()22 print(f"Estimation sample written: {len(s):,} listings")23 print(f" by category : {by_cat}")24 print(f" by province : {s.groupby('prov').size().to_dict()}")25 print(f" FSA levels : {s['fsa_c'].nunique():,} (incl. pooled residual categories)")262728if __name__ == "__main__":29 main()30