pulso-co 1.0.0rc1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. pulso_co-1.0.0rc1/.gitignore +111 -0
  2. pulso_co-1.0.0rc1/CHANGELOG.md +19 -0
  3. pulso_co-1.0.0rc1/LICENSE +21 -0
  4. pulso_co-1.0.0rc1/PKG-INFO +539 -0
  5. pulso_co-1.0.0rc1/README.md +465 -0
  6. pulso_co-1.0.0rc1/docs/CATALOG_NOTES.md +292 -0
  7. pulso_co-1.0.0rc1/docs/PHASE_3_DATA_NOTES.md +172 -0
  8. pulso_co-1.0.0rc1/docs/adr/0004-dane-catalog-scraping.md +133 -0
  9. pulso_co-1.0.0rc1/docs/adr/0005-shape-a-support.md +95 -0
  10. pulso_co-1.0.0rc1/docs/architecture.es.md +473 -0
  11. pulso_co-1.0.0rc1/docs/architecture.md +474 -0
  12. pulso_co-1.0.0rc1/docs/caveats.md +65 -0
  13. pulso_co-1.0.0rc1/docs/contributing.md +11 -0
  14. pulso_co-1.0.0rc1/docs/decisions/0001-build-plan.md +66 -0
  15. pulso_co-1.0.0rc1/docs/decisions/0002-scope-2006-present.md +38 -0
  16. pulso_co-1.0.0rc1/docs/decisions/0003-schema-1.1-area-filtering.md +162 -0
  17. pulso_co-1.0.0rc1/docs/decisions/0004-harmonizer-design.md +95 -0
  18. pulso_co-1.0.0rc1/docs/decisions/0005-phase4-roadmap.md +209 -0
  19. pulso_co-1.0.0rc1/docs/epochs.md +51 -0
  20. pulso_co-1.0.0rc1/docs/examples/README.md +9 -0
  21. pulso_co-1.0.0rc1/docs/harmonization.md +73 -0
  22. pulso_co-1.0.0rc1/docs/harmonizer-core-design.md +249 -0
  23. pulso_co-1.0.0rc1/docs/index.md +28 -0
  24. pulso_co-1.0.0rc1/docs/modules.md +24 -0
  25. pulso_co-1.0.0rc1/docs/quickstart.md +108 -0
  26. pulso_co-1.0.0rc1/pulso/__init__.py +56 -0
  27. pulso_co-1.0.0rc1/pulso/_config/__init__.py +1 -0
  28. pulso_co-1.0.0rc1/pulso/_config/epochs.py +148 -0
  29. pulso_co-1.0.0rc1/pulso/_config/registry.py +203 -0
  30. pulso_co-1.0.0rc1/pulso/_config/variables.py +52 -0
  31. pulso_co-1.0.0rc1/pulso/_core/__init__.py +1 -0
  32. pulso_co-1.0.0rc1/pulso/_core/downloader.py +124 -0
  33. pulso_co-1.0.0rc1/pulso/_core/empalme.py +389 -0
  34. pulso_co-1.0.0rc1/pulso/_core/expander.py +35 -0
  35. pulso_co-1.0.0rc1/pulso/_core/harmonizer.py +372 -0
  36. pulso_co-1.0.0rc1/pulso/_core/harmonizer_funcs.py +145 -0
  37. pulso_co-1.0.0rc1/pulso/_core/loader.py +312 -0
  38. pulso_co-1.0.0rc1/pulso/_core/merger.py +136 -0
  39. pulso_co-1.0.0rc1/pulso/_core/parser.py +384 -0
  40. pulso_co-1.0.0rc1/pulso/_utils/__init__.py +1 -0
  41. pulso_co-1.0.0rc1/pulso/_utils/cache.py +86 -0
  42. pulso_co-1.0.0rc1/pulso/_utils/columns.py +60 -0
  43. pulso_co-1.0.0rc1/pulso/_utils/exceptions.py +56 -0
  44. pulso_co-1.0.0rc1/pulso/_utils/logging.py +32 -0
  45. pulso_co-1.0.0rc1/pulso/_utils/validation.py +89 -0
  46. pulso_co-1.0.0rc1/pulso/data/_scraped_catalog.json +3465 -0
  47. pulso_co-1.0.0rc1/pulso/data/empalme_sources.json +131 -0
  48. pulso_co-1.0.0rc1/pulso/data/epochs.json +80 -0
  49. pulso_co-1.0.0rc1/pulso/data/schemas/empalme_sources.schema.json +118 -0
  50. pulso_co-1.0.0rc1/pulso/data/schemas/epochs.schema.json +147 -0
  51. pulso_co-1.0.0rc1/pulso/data/schemas/sources.schema.json +215 -0
  52. pulso_co-1.0.0rc1/pulso/data/schemas/variable_map.schema.json +173 -0
  53. pulso_co-1.0.0rc1/pulso/data/sources.json +8826 -0
  54. pulso_co-1.0.0rc1/pulso/data/variable_map.json +838 -0
  55. pulso_co-1.0.0rc1/pyproject.toml +198 -0
  56. pulso_co-1.0.0rc1/scripts/__init__.py +0 -0
  57. pulso_co-1.0.0rc1/scripts/add_month.py +150 -0
  58. pulso_co-1.0.0rc1/scripts/agent_scraper.py +68 -0
  59. pulso_co-1.0.0rc1/scripts/generate_sources_from_catalog.py +274 -0
  60. pulso_co-1.0.0rc1/scripts/replicate_official_stat.py +44 -0
  61. pulso_co-1.0.0rc1/scripts/scrape_dane_catalog.py +625 -0
  62. pulso_co-1.0.0rc1/scripts/validate_sources.py +79 -0
  63. pulso_co-1.0.0rc1/scripts/verify_checksums.py +70 -0
  64. pulso_co-1.0.0rc1/tests/__init__.py +0 -0
  65. pulso_co-1.0.0rc1/tests/_build_fixtures.py +499 -0
  66. pulso_co-1.0.0rc1/tests/conftest.py +337 -0
  67. pulso_co-1.0.0rc1/tests/fixtures/README.md +18 -0
  68. pulso_co-1.0.0rc1/tests/fixtures/zips/geih2_sample.zip +0 -0
  69. pulso_co-1.0.0rc1/tests/fixtures/zips/geih2_unified_sample.zip +0 -0
  70. pulso_co-1.0.0rc1/tests/integration/__init__.py +0 -0
  71. pulso_co-1.0.0rc1/tests/integration/_helpers.py +71 -0
  72. pulso_co-1.0.0rc1/tests/integration/_update_checksums.py +60 -0
  73. pulso_co-1.0.0rc1/tests/integration/test_harmonize_cross_epoch.py +108 -0
  74. pulso_co-1.0.0rc1/tests/integration/test_harmonize_fixture.py +333 -0
  75. pulso_co-1.0.0rc1/tests/integration/test_load_all_entries.py +58 -0
  76. pulso_co-1.0.0rc1/tests/integration/test_load_fixture.py +159 -0
  77. pulso_co-1.0.0rc1/tests/integration/test_load_merged_2015_06.py +58 -0
  78. pulso_co-1.0.0rc1/tests/integration/test_real_data_smoke.py +143 -0
  79. pulso_co-1.0.0rc1/tests/integration/test_smoothing.py +121 -0
  80. pulso_co-1.0.0rc1/tests/unit/__init__.py +0 -0
  81. pulso_co-1.0.0rc1/tests/unit/test_cache.py +106 -0
  82. pulso_co-1.0.0rc1/tests/unit/test_downloader.py +192 -0
  83. pulso_co-1.0.0rc1/tests/unit/test_empalme.py +242 -0
  84. pulso_co-1.0.0rc1/tests/unit/test_empalme_sources.py +145 -0
  85. pulso_co-1.0.0rc1/tests/unit/test_epochs.py +157 -0
  86. pulso_co-1.0.0rc1/tests/unit/test_exceptions.py +71 -0
  87. pulso_co-1.0.0rc1/tests/unit/test_harmonizer.py +370 -0
  88. pulso_co-1.0.0rc1/tests/unit/test_harmonizer_funcs.py +123 -0
  89. pulso_co-1.0.0rc1/tests/unit/test_loader.py +285 -0
  90. pulso_co-1.0.0rc1/tests/unit/test_merger.py +199 -0
  91. pulso_co-1.0.0rc1/tests/unit/test_parser.py +560 -0
  92. pulso_co-1.0.0rc1/tests/unit/test_parser_shape_a_normalization.py +84 -0
  93. pulso_co-1.0.0rc1/tests/unit/test_registry.py +252 -0
  94. pulso_co-1.0.0rc1/tests/unit/test_schemas.py +103 -0
  95. pulso_co-1.0.0rc1/tests/unit/test_smoke.py +34 -0
  96. pulso_co-1.0.0rc1/tests/unit/test_validation.py +128 -0
@@ -0,0 +1,111 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+ MANIFEST
23
+ pip-log.txt
24
+ pip-delete-this-directory.txt
25
+
26
+ # Virtual environments
27
+ .venv/
28
+ .venv-1/
29
+ .venv-pypi-test/
30
+ .venv-smoke/
31
+ venv/
32
+ env/
33
+ ENV/
34
+ .python-version
35
+
36
+ # Testing
37
+ .pytest_cache/
38
+ .coverage
39
+ .coverage.*
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ coverage.xml
44
+ *.cover
45
+ .hypothesis/
46
+
47
+ # Linting / type checking
48
+ .mypy_cache/
49
+ .ruff_cache/
50
+ .pyre/
51
+
52
+ # IDEs
53
+ .idea/
54
+ .vscode/
55
+ *.swp
56
+ *.swo
57
+ *.swn
58
+
59
+ # OS
60
+ .DS_Store
61
+ Thumbs.db
62
+ ehthumbs.db
63
+ Desktop.ini
64
+ $RECYCLE.BIN/
65
+ *.lnk
66
+
67
+ # Jupyter
68
+ .ipynb_checkpoints/
69
+ *.ipynb_checkpoints
70
+
71
+ # DANE microdata (NEVER commit, ever)
72
+ /cache/
73
+ /data_local/
74
+ /microdata/
75
+ *.parquet
76
+ *.zip
77
+ *.sav
78
+ *.dta
79
+ !tests/fixtures/zips/*.zip
80
+ !tests/fixtures/expected_outputs/*.parquet
81
+
82
+ # Scraper artifacts
83
+ scripts/.scrape_cache/
84
+ scripts/scrape_report.html
85
+ scrape_report.md
86
+ scrape_report.html
87
+
88
+ # Docs build
89
+ docs/_build/
90
+ site/
91
+
92
+ # Secrets
93
+ .env
94
+ .env.local
95
+ .env.*.local
96
+ *.key
97
+ *.pem
98
+ *.p12
99
+ secrets/
100
+
101
+ # Local notes / scratchpad
102
+ scratch/
103
+ notes-local/
104
+ TODO-personal.md
105
+
106
+ # Curator workspace (never commit downloaded ZIPs)
107
+ _workspace/
108
+ _curator_workspace/
109
+
110
+ # Claude Code session state
111
+ .claude/
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Phase 0 — Scaffolding
11
+
12
+ - Initial project structure for `pulso`
13
+ - JSON schemas for `sources.json`, `variable_map.json`, `epochs.json`
14
+ - Public API stubs (raise `NotImplementedError`)
15
+ - CI workflow (lint + tests on each PR)
16
+ - Branch path enforcement: `feat/code-*` cannot touch data, `feat/data-*` cannot touch core
17
+ - Documentation skeleton
18
+
19
+ [Unreleased]: https://github.com/Stebandido77/pulso/compare/v0.0.0...HEAD
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 pulso contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,539 @@
1
+ Metadata-Version: 2.4
2
+ Name: pulso-co
3
+ Version: 1.0.0rc1
4
+ Summary: Python library to load GEIH microdata from Colombia's DANE
5
+ Project-URL: Homepage, https://github.com/Stebandido77/pulso
6
+ Project-URL: Documentation, https://github.com/Stebandido77/pulso#readme
7
+ Project-URL: Repository, https://github.com/Stebandido77/pulso
8
+ Project-URL: Issues, https://github.com/Stebandido77/pulso/issues
9
+ Project-URL: Changelog, https://github.com/Stebandido77/pulso/blob/main/CHANGELOG.md
10
+ Author: pulso contributors
11
+ License: MIT License
12
+
13
+ Copyright (c) 2026 pulso contributors
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ of this software and associated documentation files (the "Software"), to deal
17
+ in the Software without restriction, including without limitation the rights
18
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ copies of the Software, and to permit persons to whom the Software is
20
+ furnished to do so, subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in all
23
+ copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ SOFTWARE.
32
+ License-File: LICENSE
33
+ Keywords: colombia,dane,encuesta-hogares,geih,labor-force-survey,microdata,pulso
34
+ Classifier: Development Status :: 4 - Beta
35
+ Classifier: Intended Audience :: Science/Research
36
+ Classifier: License :: OSI Approved :: MIT License
37
+ Classifier: Natural Language :: English
38
+ Classifier: Natural Language :: Spanish
39
+ Classifier: Operating System :: OS Independent
40
+ Classifier: Programming Language :: Python :: 3
41
+ Classifier: Programming Language :: Python :: 3.10
42
+ Classifier: Programming Language :: Python :: 3.11
43
+ Classifier: Programming Language :: Python :: 3.12
44
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
45
+ Classifier: Topic :: Sociology
46
+ Requires-Python: >=3.10
47
+ Requires-Dist: jsonschema>=4.20
48
+ Requires-Dist: pandas>=2.0
49
+ Requires-Dist: platformdirs>=4.0
50
+ Requires-Dist: pyarrow>=14.0
51
+ Requires-Dist: requests>=2.31
52
+ Requires-Dist: tqdm>=4.66
53
+ Provides-Extra: dev
54
+ Requires-Dist: mypy>=1.8; extra == 'dev'
55
+ Requires-Dist: pandas-stubs; extra == 'dev'
56
+ Requires-Dist: pytest-cov>=4.1; extra == 'dev'
57
+ Requires-Dist: pytest-mock>=3.12; extra == 'dev'
58
+ Requires-Dist: pytest-xdist>=3.5; extra == 'dev'
59
+ Requires-Dist: pytest>=8.0; extra == 'dev'
60
+ Requires-Dist: ruff>=0.4; extra == 'dev'
61
+ Requires-Dist: types-jsonschema; extra == 'dev'
62
+ Requires-Dist: types-requests; extra == 'dev'
63
+ Provides-Extra: docs
64
+ Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
65
+ Requires-Dist: mkdocs>=1.5; extra == 'docs'
66
+ Requires-Dist: mkdocstrings[python]>=0.24; extra == 'docs'
67
+ Provides-Extra: legacy
68
+ Requires-Dist: pyreadstat>=1.2; extra == 'legacy'
69
+ Provides-Extra: scraper
70
+ Requires-Dist: beautifulsoup4>=4.12; extra == 'scraper'
71
+ Requires-Dist: lxml>=5.0; extra == 'scraper'
72
+ Requires-Dist: playwright>=1.40; extra == 'scraper'
73
+ Description-Content-Type: text/markdown
74
+
75
+ # pulso
76
+
77
+ > **El pulso del mercado laboral colombiano.**
78
+ > *Python library to load GEIH microdata from Colombia's DANE.*
79
+
80
+ [![CI](https://github.com/Stebandido77/pulso/actions/workflows/ci.yml/badge.svg)](https://github.com/Stebandido77/pulso/actions/workflows/ci.yml)
81
+ [![PyPI version](https://img.shields.io/pypi/v/pulso.svg)](https://pypi.org/project/pulso/)
82
+ [![Python](https://img.shields.io/pypi/pyversions/pulso.svg)](https://pypi.org/project/pulso/)
83
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
84
+
85
+ ---
86
+
87
+ [**Español**](#español) | [**English**](#english)
88
+
89
+ ---
90
+
91
+ <a id="español"></a>
92
+
93
+ ## 🇨🇴 Español
94
+
95
+ ### ¿Qué es `pulso`?
96
+
97
+ `pulso` es una librería de Python que da acceso directo a la **Gran Encuesta Integrada de Hogares (GEIH)** — la encuesta mensual de hogares que publica el DANE de Colombia. Sin descargas manuales, sin lidiar con ZIPs, sin problemas de codificación.
98
+
99
+ Tres cosas que hace:
100
+
101
+ - **Descarga** — obtiene el ZIP oficial del portal de microdatos del DANE, lo cachea localmente y verifica SHA-256.
102
+ - **Parsea** — maneja tres formatos estructurales (Shape A: archivos Cabecera/Resto para 2006–2021; Shape B: archivo unificado nacional para 2022–presente; Shape C: ZIPs anuales Empalme).
103
+ - **Armoniza** — mapea los códigos de columna crudos del DANE (`P6020`, `FEX_C18`, …) a variables canónicas nombradas (`sexo`, `peso_expansion`, …) de forma consistente entre épocas metodológicas.
104
+
105
+ ```python
106
+ import pulso
107
+
108
+ # Cargar un módulo, un mes
109
+ df = pulso.load(year=2024, month=6, module="ocupados")
110
+
111
+ # Serie temporal
112
+ df = pulso.load(year=range(2018, 2025), month=6, module="ocupados")
113
+
114
+ # Merge entre módulos
115
+ df = pulso.load_merged(year=2024, month=6,
116
+ modules=["ocupados", "caracteristicas_generales"])
117
+
118
+ # Carga con empalme entre épocas (2010–2019)
119
+ df = pulso.load_merged(year=2015, month=6, apply_smoothing=True)
120
+
121
+ # Dataset anual del Empalme GEIH
122
+ df_empalme = pulso.load_empalme(year=2015, harmonize=True)
123
+ ```
124
+
125
+ ### Cobertura
126
+
127
+ | Atributo | Detalle |
128
+ |----------|---------|
129
+ | **Período** | 2006-01 al presente (último mes publicado por el DANE) |
130
+ | **Cobertura geográfica** | Nacional: cabecera (urbano) + resto (rural), 23 ciudades y áreas metropolitanas |
131
+ | **Módulos** | `caracteristicas_generales`, `ocupados`, `desocupados`, `inactivos`, `vivienda_hogares`, `otros_ingresos`, `migracion`\*, `otras_formas_trabajo`\* |
132
+ | **Meses validados** | 2007-12, 2015-06, 2021-12, 2022-01, 2024-06 (end-to-end con datos reales del DANE) |
133
+ | **Entradas en el registro** | ~230 meses (2006-01 → 2026-02) |
134
+
135
+ \* Disponibles solo en la época `geih_2021_present` (desde 2022-01).
136
+
137
+ > **Fuera del alcance:** La Encuesta Continua de Hogares (ECH, 2000–2005) no está incluida. La ECH usa un marco muestral, definiciones y cobertura geográfica distintos; mezclarla con la GEIH bajo una API armonizada sería engañoso.
138
+
139
+ ### Épocas metodológicas
140
+
141
+ El DANE cambió significativamente la metodología de la GEIH en 2022. `pulso` modela esto como dos épocas:
142
+
143
+ | Clave de época | Período | Marco muestral | Variable de expansión |
144
+ |----------------|---------|----------------|----------------------|
145
+ | `geih_2006_2020` | 2006-01 → 2021-12 | Censo 2005 | `FEX_C` |
146
+ | `geih_2021_present` | **2022-01** → presente | Censo 2018 (post-OIT) | `FEX_C18` |
147
+
148
+ > ⚠️ El cambio de época está en **2022-01**, no en 2021. Las estimaciones que cruzan este límite llevan una advertencia de comparabilidad documentada.
149
+
150
+ ### Empalme entre épocas
151
+
152
+ El DANE publica la serie **GEIH Empalme** (2010–2020) — ZIPs anuales que re-estiman los microdatos mensuales bajo el marco unificado del Censo 2005. Es la herramienta estándar para construir series de tiempo consistentes antes del rediseño de 2022.
153
+
154
+ `pulso` expone dos formas de usarlo:
155
+
156
+ ```python
157
+ # Intercambio transparente: carga 2015-06 con datos Empalme en vez de GEIH cruda
158
+ df = pulso.load_merged(year=2015, month=6, harmonize=True, apply_smoothing=True)
159
+
160
+ # Acceso directo: los 12 meses del Empalme 2015 apilados
161
+ df_empalme = pulso.load_empalme(year=2015, module="ocupados", harmonize=True)
162
+ ```
163
+
164
+ Los ZIPs del Empalme se cachean en `empalme/{year}.zip`.
165
+ El año 2020 existe en el catálogo del DANE pero el ZIP no ha sido publicado; `load_empalme(2020)` lanza `DataNotAvailableError`.
166
+
167
+ ### Instalación
168
+
169
+ ```bash
170
+ pip install pulso
171
+ ```
172
+
173
+ ### Quickstart
174
+
175
+ ```python
176
+ import pulso
177
+
178
+ # 1. Ver qué hay disponible
179
+ disponible = pulso.list_available() # todos los meses
180
+ disponible_2024 = pulso.list_available(year=2024)
181
+
182
+ # 2. Listar módulos canónicos
183
+ pulso.list_modules()
184
+
185
+ # 3. Cargar un módulo
186
+ df = pulso.load(year=2024, month=6, module="caracteristicas_generales", area="total")
187
+
188
+ # 4. Merge entre módulos con armonización
189
+ df = pulso.load_merged(
190
+ year=2024, month=6,
191
+ modules=["ocupados", "caracteristicas_generales"],
192
+ harmonize=True,
193
+ )
194
+
195
+ # 5. Aplicar factores de expansión (decisión consciente, no automática)
196
+ df_expandido = pulso.expand(df, weight="peso_expansion")
197
+ ```
198
+
199
+ ### API pública
200
+
201
+ | Función | Estado | Descripción |
202
+ |---------|--------|-------------|
203
+ | `load(year, month, module, ...)` | ✅ estable | Carga un módulo para uno o más períodos |
204
+ | `load_merged(year, month, modules, ..., apply_smoothing)` | ✅ estable | Carga y merge de módulos; intercambio Empalme opcional |
205
+ | `load_empalme(year, module, area, harmonize)` | ✅ estable | Carga el dataset anual GEIH Empalme (2010–2019) |
206
+ | `expand(df, weight)` | ✅ estable | Aplica factores de expansión fila a fila |
207
+ | `list_available(year)` | ✅ estable | DataFrame de pares (año, mes) disponibles |
208
+ | `list_modules()` | ✅ estable | DataFrame de definiciones de módulos canónicos |
209
+ | `cache_info()` | ✅ estable | Resumen de tamaño y estructura del caché |
210
+ | `cache_clear(level)` | ✅ estable | Limpia raw / parsed / harmonized / todo |
211
+ | `cache_path()` | ✅ estable | Ruta absoluta al directorio de caché |
212
+ | `data_version()` | ✅ estable | Versión del registro de datos (ej. `"2026.04"`) |
213
+ | `list_variables()` | 🚧 planeada | Listar variables armonizadas canónicas |
214
+ | `describe_variable(name)` | 🚧 planeada | Definición + notas de comparabilidad |
215
+ | `describe_harmonization(variable)` | 🚧 planeada | Detalle del mapeo por época |
216
+ | `describe(module, year)` | 🚧 planeada | Metadatos del módulo + info de época |
217
+
218
+ ### Caché local
219
+
220
+ Los microdatos descargados se guardan en el directorio predeterminado de la plataforma (gestionado por `platformdirs`):
221
+
222
+ | SO | Ruta de caché por defecto |
223
+ |----|--------------------------|
224
+ | Linux / macOS | `~/.cache/pulso/` |
225
+ | Windows | `%LOCALAPPDATA%\pulso\pulso\Cache\` |
226
+
227
+ Estructura:
228
+
229
+ ```
230
+ <raíz_caché>/
231
+ ├── raw/{year}/{month:02d}/{checksum_short}.zip # ZIP original del DANE
232
+ ├── empalme/{year}.zip # ZIPs anuales Empalme
233
+ ├── parsed/{year}/{month:02d}/{module}.parquet # post-parser (futuro)
234
+ └── harmonized/{year}/{month:02d}/{module}.parquet # post-armonización (futuro)
235
+ ```
236
+
237
+ Inspeccionar y gestionar:
238
+
239
+ ```python
240
+ pulso.cache_info() # tamaño, conteo de archivos, por nivel
241
+ pulso.cache_path() # ruta absoluta
242
+ pulso.cache_clear(level="raw") # limpiar un nivel
243
+ pulso.cache_clear(level="all") # borrar todo
244
+ ```
245
+
246
+ ### Caveats importantes
247
+
248
+ Antes de usar los resultados en una publicación, lee [`docs/caveats.md`](docs/caveats.md):
249
+
250
+ 1. **La armonización no elimina las discontinuidades metodológicas reales del DANE.** El rediseño de 2022 cambió definiciones, marco muestral y cobertura geográfica. Trata las comparaciones entre épocas (especialmente antes/después de 2022) con cuidado.
251
+ 2. **`expand()` ignora el diseño muestral.** Sumar pesos expandidos con `groupby().sum()` produce estimaciones puntuales pero no errores estándar correctos. Para inferencia rigurosa usa un paquete de análisis de encuestas (ej. `samplics`).
252
+ 3. **No es un producto oficial del DANE.** Para uso oficial, consulta el portal de microdatos: <https://microdatos.dane.gov.co/>
253
+
254
+ ### Por qué `pulso` y no `geih`
255
+
256
+ `pulso` es el nombre del paquete; `GEIH` es la encuesta que carga hoy. La distinción importa: si en el futuro se agregan otras encuestas del DANE (ej. ENPH, ECV), pueden vivir en sub-namespaces (`pulso.enph`, `pulso.ecv`) sin romper el namespace raíz. Hoy, `pulso.load(...)` siempre carga GEIH.
257
+
258
+ ### Estado del proyecto
259
+
260
+ Versión actual: **v1.0.0-rc1** (release candidate). Disponible en [TestPyPI](https://test.pypi.org/project/pulso/).
261
+
262
+ | Fase | Descripción | Estado |
263
+ |------|-------------|--------|
264
+ | 0 | Andamiaje | ✅ |
265
+ | 1 | Vertical slice — un mes | ✅ |
266
+ | 2 | Harmonizer y merger | ✅ |
267
+ | 3 | Cobertura GEIH completa (2006–presente) | ✅ |
268
+ | 3.5 | Empalme loader + apply_smoothing | ✅ |
269
+ | 4 | Deuda técnica + normalización Shape A | ✅ |
270
+ | 5 | Release en PyPI | 🚧 |
271
+
272
+ Ver [`CHANGELOG.md`](CHANGELOG.md) para más detalles.
273
+
274
+ ### Contribuir
275
+
276
+ Ver [`CONTRIBUTING.md`](CONTRIBUTING.md). Especialmente útil si:
277
+
278
+ - Quieres reportar un mes que falla al cargar
279
+ - Quieres proponer una nueva variable armonizada
280
+ - Encuentras una discrepancia con estadísticas oficiales del DANE
281
+
282
+ ### Citación
283
+
284
+ Si usas este paquete en una publicación, cita el DANE como fuente primaria de los datos, y opcionalmente este paquete como herramienta:
285
+
286
+ ```text
287
+ DANE (2024). Gran Encuesta Integrada de Hogares (GEIH).
288
+ Departamento Administrativo Nacional de Estadística.
289
+ https://microdatos.dane.gov.co/
290
+
291
+ Labastidas, E. (2026). pulso: Python library to load GEIH microdata from Colombia's DANE.
292
+ https://github.com/Stebandido77/pulso
293
+ ```
294
+
295
+ ### Licencia
296
+
297
+ El código está bajo licencia MIT (ver [`LICENSE`](LICENSE)). Los microdatos descargados son propiedad del DANE y se rigen por los términos de uso del portal de microdatos.
298
+
299
+ ---
300
+
301
+ <a id="english"></a>
302
+
303
+ ## 🇬🇧 English
304
+
305
+ ### What is pulso?
306
+
307
+ `pulso` is a Python library that gives you single-line access to Colombia's **Gran Encuesta Integrada de Hogares (GEIH)** — the monthly household survey published by DANE, the national statistics office. No manual downloads, no ZIP wrangling, no encoding headaches.
308
+
309
+ Three things it does:
310
+
311
+ - **Download** — fetches the official ZIP from DANE's microdata portal, caches it locally, verifies SHA-256.
312
+ - **Parse** — handles three structural formats (Shape A: Cabecera/Resto split for 2006–2021; Shape B: unified nationwide file for 2022–present; Shape C: Empalme annual ZIPs).
313
+ - **Harmonize** — maps raw DANE column codes (`P6020`, `FEX_C18`, …) to named canonical variables (`sexo`, `peso_expansion`, …) consistently across methodological epochs.
314
+
315
+ ```python
316
+ import pulso
317
+
318
+ # Load one module, one month
319
+ df = pulso.load(year=2024, month=6, module="ocupados")
320
+
321
+ # Time series across years
322
+ df = pulso.load(year=range(2018, 2025), month=6, module="ocupados")
323
+
324
+ # Multi-module merge
325
+ df = pulso.load_merged(year=2024, month=6,
326
+ modules=["ocupados", "caracteristicas_generales"])
327
+
328
+ # Epoch-smoothed load using GEIH Empalme (2010–2019)
329
+ df = pulso.load_merged(year=2015, month=6, apply_smoothing=True)
330
+
331
+ # Load the full Empalme annual dataset
332
+ df_empalme = pulso.load_empalme(year=2015, harmonize=True)
333
+ ```
334
+
335
+ ### Coverage
336
+
337
+ | Attribute | Detail |
338
+ |-----------|--------|
339
+ | **Period** | 2006-01 to present (latest month published by DANE) |
340
+ | **Geography** | National: cabecera (urban) + resto (rural), 23 cities and metro areas |
341
+ | **Modules** | `caracteristicas_generales`, `ocupados`, `desocupados`, `inactivos`, `vivienda_hogares`, `otros_ingresos`, `migracion`\*, `otras_formas_trabajo`\* |
342
+ | **Validated months** | 2007-12, 2015-06, 2021-12, 2022-01, 2024-06 (end-to-end with real DANE data) |
343
+ | **Registry entries** | ~230 monthly entries (2006-01 → 2026-02) |
344
+
345
+ \* Available only in `geih_2021_present` epoch (2022-01 onward).
346
+
347
+ > **Out of scope:** The Encuesta Continua de Hogares (ECH, 2000–2005) is not included. ECH uses a different sampling frame, definitions, and coverage; merging it with GEIH under a single harmonized API would be misleading.
348
+
349
+ ### Methodological epochs
350
+
351
+ DANE changed the GEIH methodology significantly in 2022. `pulso` models this as two epochs:
352
+
353
+ | Epoch key | Period | Sampling frame | Weight variable |
354
+ |-----------|--------|----------------|-----------------|
355
+ | `geih_2006_2020` | 2006-01 → 2021-12 | 2005 census | `FEX_C` |
356
+ | `geih_2021_present` | **2022-01** → present | 2018 census (post-ILO) | `FEX_C18` |
357
+
358
+ > ⚠️ The epoch boundary is **2022-01**, not 2021. Estimates that span this boundary carry a documented comparability warning.
359
+
360
+ ### Smoothing across the epoch boundary (Empalme)
361
+
362
+ DANE publishes the **GEIH Empalme** series (2010–2020) — annual ZIPs that re-estimate monthly microdata under the unified 2005-census framework. This is the standard tool for constructing consistent multi-year time series before the 2022 redesign.
363
+
364
+ `pulso` exposes two ways to use it:
365
+
366
+ ```python
367
+ # Transparent swap: load 2015-06 using Empalme data instead of raw GEIH
368
+ df = pulso.load_merged(year=2015, month=6, harmonize=True, apply_smoothing=True)
369
+
370
+ # Direct access: all 12 months of Empalme 2015 stacked
371
+ df = pulso.load_empalme(year=2015, module="ocupados", harmonize=True)
372
+ ```
373
+
374
+ Empalme ZIPs are cached separately under `empalme/{year}.zip`.
375
+ Year 2020 exists in DANE's catalog but the ZIP has not been published; `load_empalme(2020)` raises `DataNotAvailableError`.
376
+
377
+ ### Installation
378
+
379
+ ```bash
380
+ pip install pulso
381
+ ```
382
+
383
+ ### Quickstart
384
+
385
+ ```python
386
+ import pulso
387
+
388
+ # 1. See what's available
389
+ available = pulso.list_available() # all months
390
+ available_2024 = pulso.list_available(year=2024)
391
+
392
+ # 2. List canonical modules
393
+ pulso.list_modules()
394
+
395
+ # 3. Load a single module
396
+ df = pulso.load(year=2024, month=6, module="caracteristicas_generales", area="total")
397
+
398
+ # 4. Multi-module merge with harmonization
399
+ df = pulso.load_merged(
400
+ year=2024, month=6,
401
+ modules=["ocupados", "caracteristicas_generales"],
402
+ harmonize=True,
403
+ )
404
+
405
+ # 5. Apply expansion factors (conscious choice — not automatic)
406
+ df_expanded = pulso.expand(df, weight="peso_expansion")
407
+ ```
408
+
409
+ ### Public API
410
+
411
+ | Function | Status | Description |
412
+ |----------|--------|-------------|
413
+ | `load(year, month, module, ...)` | ✅ stable | Load one module for one or more periods |
414
+ | `load_merged(year, month, modules, ..., apply_smoothing)` | ✅ stable | Load + merge multiple modules; optional Empalme swap |
415
+ | `load_empalme(year, module, area, harmonize)` | ✅ stable | Load GEIH Empalme annual dataset (2010–2019) |
416
+ | `expand(df, weight)` | ✅ stable | Apply expansion factors row-by-row |
417
+ | `list_available(year)` | ✅ stable | DataFrame of available (year, month) pairs |
418
+ | `list_modules()` | ✅ stable | DataFrame of canonical module definitions |
419
+ | `cache_info()` | ✅ stable | Cache size and layout summary |
420
+ | `cache_clear(level)` | ✅ stable | Clear raw / parsed / harmonized / all |
421
+ | `cache_path()` | ✅ stable | Absolute path to cache root |
422
+ | `data_version()` | ✅ stable | Registry data version (e.g. `"2026.04"`) |
423
+ | `list_variables()` | 🚧 planned | List canonical harmonized variables |
424
+ | `describe_variable(name)` | 🚧 planned | Variable definition + comparability notes |
425
+ | `describe_harmonization(variable)` | 🚧 planned | Per-epoch mapping details |
426
+ | `describe(module, year)` | 🚧 planned | Module metadata + epoch info |
427
+
428
+ ### Local cache
429
+
430
+ Downloaded microdata is cached under the platform default directory (managed by `platformdirs`):
431
+
432
+ | OS | Default cache path |
433
+ |----|--------------------|
434
+ | Linux / macOS | `~/.cache/pulso/` |
435
+ | Windows | `%LOCALAPPDATA%\pulso\pulso\Cache\` |
436
+
437
+ Layout:
438
+
439
+ ```
440
+ <cache_root>/
441
+ ├── raw/{year}/{month:02d}/{checksum_short}.zip # original DANE ZIP
442
+ ├── empalme/{year}.zip # Empalme annual ZIPs
443
+ ├── parsed/{year}/{month:02d}/{module}.parquet # post-parser (future)
444
+ └── harmonized/{year}/{month:02d}/{module}.parquet # post-harmonize (future)
445
+ ```
446
+
447
+ Inspect and manage:
448
+
449
+ ```python
450
+ pulso.cache_info() # size, file count, by level
451
+ pulso.cache_path() # absolute path
452
+ pulso.cache_clear(level="raw") # clear one level
453
+ pulso.cache_clear(level="all") # clear everything
454
+ ```
455
+
456
+ ### Important caveats
457
+
458
+ Before using results in a publication, please read [`docs/caveats.md`](docs/caveats.md):
459
+
460
+ 1. **Harmonization does not remove real DANE discontinuities.** The 2022 redesign changed definitions, sampling frame, and geographic coverage. Treat cross-epoch comparisons (especially pre/post 2022) with care.
461
+ 2. **`expand()` ignores sampling design.** Summing expanded weights with `groupby().sum()` yields point estimates but no correct standard errors. For rigorous inference, use a survey analysis package (e.g. `samplics`).
462
+ 3. **Not an official DANE product.** For official use, refer to DANE's microdata portal: <https://microdatos.dane.gov.co/>
463
+
464
+ ### Why "pulso" and not "geih"
465
+
466
+ `pulso` is the package name; `GEIH` is the survey it loads today. The distinction matters: if future versions add other DANE surveys (e.g. ENPH, ECV), they can live in sub-namespaces (`pulso.enph`, `pulso.ecv`) without breaking the root namespace. For now, `pulso.load(...)` always loads GEIH.
467
+
468
+ ### Status
469
+
470
+ Current version: **v1.0.0-rc1** (release candidate). Available on [TestPyPI](https://test.pypi.org/project/pulso/).
471
+
472
+ | Phase | Description | Status |
473
+ |-------|-------------|--------|
474
+ | 0 | Scaffolding | ✅ |
475
+ | 1 | Vertical slice — single month | ✅ |
476
+ | 2 | Harmonizer and merger | ✅ |
477
+ | 3 | Full GEIH coverage (2006–present) | ✅ |
478
+ | 3.5 | Empalme loader + smoothing | ✅ |
479
+ | 4 | Technical debt + Shape A normalization | ✅ |
480
+ | 5 | PyPI release | 🚧 |
481
+
482
+ See [`CHANGELOG.md`](CHANGELOG.md) for details.
483
+
484
+ ### Contributing
485
+
486
+ See [`CONTRIBUTING.md`](CONTRIBUTING.md). Especially welcome:
487
+
488
+ - Reporting a month that fails to load
489
+ - Proposing a new harmonized variable
490
+ - Finding a discrepancy with official DANE statistics
491
+
492
+ ### Citation
493
+
494
+ If you use this package in a publication, cite DANE as the primary data source, and optionally this package as the tool:
495
+
496
+ ```text
497
+ DANE (2024). Gran Encuesta Integrada de Hogares (GEIH).
498
+ Departamento Administrativo Nacional de Estadística.
499
+ https://microdatos.dane.gov.co/
500
+
501
+ Labastidas, E. (2026). pulso: Python library to load GEIH microdata from Colombia's DANE.
502
+ https://github.com/Stebandido77/pulso
503
+ ```
504
+
505
+ ### License
506
+
507
+ Code is MIT-licensed (see [`LICENSE`](LICENSE)). Downloaded microdata belongs to DANE and is governed by the terms of use of the microdata portal.
508
+
509
+ ---
510
+
511
+ ## Créditos
512
+
513
+ `pulso` fue creado por **Esteban Labastidas** ([@Stebandido77](https://github.com/Stebandido77)).
514
+
515
+ El paquete fue construido usando un sistema multi-agente de codificación basado en Claude (Anthropic), diseñado y dirigido por el autor:
516
+
517
+ - **Architect** (Claude Opus, chat): diseño arquitectónico, RFCs, revisión y coordinación de PRs
518
+ - **Builder** (Claude Code): implementación de código en `pulso/_core/`
519
+ - **Curator** (Claude Code): gestión del catálogo de datos en `pulso/data/`
520
+
521
+ La arquitectura del sistema multi-agente, las decisiones técnicas y el diseño del paquete son obra del autor. Los agentes ejecutan implementación bajo supervisión y dirección humana directa.
522
+
523
+ Ver [`docs/architecture.md`](docs/architecture.md) sección 6 para detalles del modelo de construcción.
524
+
525
+ ---
526
+
527
+ ## Credits
528
+
529
+ `pulso` was created by **Esteban Labastidas** ([@Stebandido77](https://github.com/Stebandido77)).
530
+
531
+ The package was built using a Claude-based (Anthropic) multi-agent coding system, designed and directed by the author:
532
+
533
+ - **Architect** (Claude Opus, chat): architectural design, RFCs, PR review and coordination
534
+ - **Builder** (Claude Code): code implementation in `pulso/_core/`
535
+ - **Curator** (Claude Code): data catalog management in `pulso/data/`
536
+
537
+ The multi-agent system architecture, technical decisions, and package design are the author's work. The agents execute implementation under direct human supervision and direction.
538
+
539
+ See [`docs/architecture.md`](docs/architecture.md) section 6 for build model details.