unicefdata 2.4.1__tar.gz → 3.0.0__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 (199) hide show
  1. unicefdata-3.0.0/PKG-INFO +1383 -0
  2. unicefdata-3.0.0/README.md +1342 -0
  3. {unicefdata-2.4.1 → unicefdata-3.0.0}/pyproject.toml +1 -1
  4. unicefdata-3.0.0/tests/test_age_parameter.py +199 -0
  5. unicefdata-3.0.0/tests/test_build_dataflow_metadata_header.py +110 -0
  6. unicefdata-3.0.0/tests/test_cascade_on_empty.py +286 -0
  7. unicefdata-3.0.0/tests/test_cascade_on_empty_integration.py +74 -0
  8. unicefdata-3.0.0/tests/test_circa.py +67 -0
  9. unicefdata-3.0.0/tests/test_cli_alignment.py +223 -0
  10. unicefdata-3.0.0/tests/test_codelist_value_label.py +53 -0
  11. unicefdata-3.0.0/tests/test_country_aggregates.py +450 -0
  12. unicefdata-3.0.0/tests/test_dataflow_resolution.py +151 -0
  13. unicefdata-3.0.0/tests/test_dataflows_normalization.py +85 -0
  14. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_deterministic.py +34 -18
  15. unicefdata-3.0.0/tests/test_dimensions_for.py +98 -0
  16. unicefdata-3.0.0/tests/test_download_summary.py +97 -0
  17. unicefdata-3.0.0/tests/test_failed_requests.py +93 -0
  18. unicefdata-3.0.0/tests/test_fallback_optout.py +107 -0
  19. unicefdata-3.0.0/tests/test_first_class_dims.py +148 -0
  20. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_hardcoded_removal_validation.py +6 -2
  21. unicefdata-3.0.0/tests/test_indicator_card.py +1118 -0
  22. unicefdata-3.0.0/tests/test_list_indicators_filters.py +72 -0
  23. unicefdata-3.0.0/tests/test_other_dimension_totals.py +55 -0
  24. unicefdata-3.0.0/tests/test_package_completeness.py +125 -0
  25. unicefdata-3.0.0/tests/test_partial_fetch_guard.py +34 -0
  26. unicefdata-3.0.0/tests/test_pass3d.py +309 -0
  27. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_pipeline_mocked.py +12 -0
  28. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_query_status.py +101 -1
  29. unicefdata-3.0.0/tests/test_rdm_client.py +457 -0
  30. unicefdata-3.0.0/tests/test_rdm_enrichment.py +392 -0
  31. unicefdata-3.0.0/tests/test_rdm_sync_honesty.py +49 -0
  32. unicefdata-3.0.0/tests/test_registry_cache_location.py +62 -0
  33. unicefdata-3.0.0/tests/test_sdmx_forbidden_error_envelope.py +153 -0
  34. unicefdata-3.0.0/tests/test_sdmx_not_found_fields.py +75 -0
  35. unicefdata-3.0.0/tests/test_selection_cases.py +166 -0
  36. unicefdata-3.0.0/tests/test_selection_parity.py +294 -0
  37. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_sync_pipeline.py +7 -7
  38. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/__init__.py +48 -4
  39. unicefdata-3.0.0/unicefdata/aggregates.py +427 -0
  40. unicefdata-3.0.0/unicefdata/crm_client.py +665 -0
  41. unicefdata-3.0.0/unicefdata/dimensions.py +279 -0
  42. unicefdata-3.0.0/unicefdata/indicator_card.py +1708 -0
  43. unicefdata-3.0.0/unicefdata/indicator_registry.py +1196 -0
  44. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/_unicefdata_codelists.yaml +11 -11
  45. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/_unicefdata_countries.yaml +139 -134
  46. unicefdata-3.0.0/unicefdata/metadata/current/_unicefdata_country_aggregates.yaml +2321 -0
  47. unicefdata-3.0.0/unicefdata/metadata/current/_unicefdata_dataflow_metadata.yaml +1300 -0
  48. unicefdata-3.0.0/unicefdata/metadata/current/_unicefdata_indicator_details.yaml +1761 -0
  49. unicefdata-3.0.0/unicefdata/metadata/current/_unicefdata_indicators.yaml +13248 -0
  50. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/_unicefdata_indicators_metadata.yaml +591 -72
  51. unicefdata-3.0.0/unicefdata/metadata/current/_unicefdata_rdm_reference_only.yaml +2444 -0
  52. unicefdata-3.0.0/unicefdata/metadata/current/_unicefdata_rdm_vocabulary.yaml +1571 -0
  53. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/unicef_indicators_metadata.yaml +14 -14
  54. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata.py +143 -41
  55. unicefdata-3.0.0/unicefdata/rdm_client.py +1518 -0
  56. unicefdata-3.0.0/unicefdata/rdm_record.py +238 -0
  57. unicefdata-3.0.0/unicefdata/run_sync.py +56 -0
  58. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/schema_sync.py +26 -1
  59. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/sdmx_client.py +624 -106
  60. unicefdata-3.0.0/unicefdata/unicefdata.py +2641 -0
  61. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/utils.py +6 -1
  62. unicefdata-3.0.0/unicefdata.egg-info/PKG-INFO +1383 -0
  63. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata.egg-info/SOURCES.txt +40 -0
  64. unicefdata-2.4.1/PKG-INFO +0 -892
  65. unicefdata-2.4.1/README.md +0 -851
  66. unicefdata-2.4.1/unicefdata/indicator_registry.py +0 -776
  67. unicefdata-2.4.1/unicefdata/metadata/current/_unicefdata_indicators.yaml +0 -7270
  68. unicefdata-2.4.1/unicefdata/run_sync.py +0 -20
  69. unicefdata-2.4.1/unicefdata/unicefdata.py +0 -1397
  70. unicefdata-2.4.1/unicefdata.egg-info/PKG-INFO +0 -892
  71. {unicefdata-2.4.1 → unicefdata-3.0.0}/LICENSE +0 -0
  72. {unicefdata-2.4.1 → unicefdata-3.0.0}/setup.cfg +0 -0
  73. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_404_fallback.py +0 -0
  74. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_dimensions.py +0 -0
  75. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_direct_metadata.py +0 -0
  76. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_discovery.py +0 -0
  77. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_download.py +0 -0
  78. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_error_conditions.py +0 -0
  79. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_fallback_fix.py +0 -0
  80. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_list_dataflows.py +0 -0
  81. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_metadata_manager.py +0 -0
  82. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_python_integration.py +0 -0
  83. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_quick_python.py +0 -0
  84. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_sdmx_client_dataflow.py +0 -0
  85. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_transformations.py +0 -0
  86. {unicefdata-2.4.1 → unicefdata-3.0.0}/tests/test_unicef_api.py +0 -0
  87. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/config.py +0 -0
  88. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/config_loader.py +0 -0
  89. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/flows.py +0 -0
  90. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/_unicefdata_sync_history.yaml +0 -0
  91. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/_dataflow_fallback_sequences.yaml +0 -0
  92. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/_unicefdata_dataflows.yaml +0 -0
  93. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/_unicefdata_regions.yaml +0 -0
  94. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflow_index.yaml +0 -0
  95. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CAUSE_OF_DEATH.yaml +0 -0
  96. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CCRI.yaml +0 -0
  97. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CHILD_RELATED_SDG.yaml +0 -0
  98. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CHLD_PVTY.yaml +0 -0
  99. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME.yaml +0 -0
  100. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_CAUSE_OF_DEATH.yaml +0 -0
  101. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_COUNTRY_PROFILES_DATA.yaml +0 -0
  102. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_DF_2021_WQ.yaml +0 -0
  103. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNATIONAL.yaml +0 -0
  104. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_AGO.yaml +0 -0
  105. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_BDI.yaml +0 -0
  106. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_BEN.yaml +0 -0
  107. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_BGD.yaml +0 -0
  108. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_CMR.yaml +0 -0
  109. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_ETH.yaml +0 -0
  110. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_GHA.yaml +0 -0
  111. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_GIN.yaml +0 -0
  112. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_HTI.yaml +0 -0
  113. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_KEN.yaml +0 -0
  114. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_LAO.yaml +0 -0
  115. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_LBR.yaml +0 -0
  116. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_LSO.yaml +0 -0
  117. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_MDG.yaml +0 -0
  118. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_MLI.yaml +0 -0
  119. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_MMR.yaml +0 -0
  120. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_MRT.yaml +0 -0
  121. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_MWI.yaml +0 -0
  122. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_NAM.yaml +0 -0
  123. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_NGA.yaml +0 -0
  124. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_NPL.yaml +0 -0
  125. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_PAK.yaml +0 -0
  126. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_RWA.yaml +0 -0
  127. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_SEN.yaml +0 -0
  128. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_SLE.yaml +0 -0
  129. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_TCD.yaml +0 -0
  130. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_TGO.yaml +0 -0
  131. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_TZA.yaml +0 -0
  132. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_UGA.yaml +0 -0
  133. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_ZMB.yaml +0 -0
  134. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/CME_SUBNAT_ZWE.yaml +0 -0
  135. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/COVID.yaml +0 -0
  136. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/COVID_CASES.yaml +0 -0
  137. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/DM.yaml +0 -0
  138. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/DM_PROJECTIONS.yaml +0 -0
  139. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/ECD.yaml +0 -0
  140. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/ECONOMIC.yaml +0 -0
  141. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/EDUCATION.yaml +0 -0
  142. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/EDUCATION_FLS.yaml +0 -0
  143. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/EDUCATION_UIS_SDG.yaml +0 -0
  144. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/FUNCTIONAL_DIFF.yaml +0 -0
  145. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/GENDER.yaml +0 -0
  146. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/GLOBAL_DATAFLOW.yaml +0 -0
  147. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/HIV_AIDS.yaml +0 -0
  148. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/IMMUNISATION.yaml +0 -0
  149. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/MG.yaml +0 -0
  150. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/MNCH.yaml +0 -0
  151. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/NUTRITION.yaml +0 -0
  152. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/PT.yaml +0 -0
  153. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/PT_CM.yaml +0 -0
  154. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/PT_CM_SUBNATIONAL.yaml +0 -0
  155. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/PT_CONFLICT.yaml +0 -0
  156. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/PT_FGM.yaml +0 -0
  157. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/SDG_PROG_ASSESSMENT.yaml +0 -0
  158. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/SOC_PROTECTION.yaml +0 -0
  159. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/WASH_HEALTHCARE_FACILITY.yaml +0 -0
  160. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/WASH_HOUSEHOLDS.yaml +0 -0
  161. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/WASH_HOUSEHOLD_MH.yaml +0 -0
  162. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/WASH_HOUSEHOLD_SUBNAT.yaml +0 -0
  163. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/WASH_SCHOOLS.yaml +0 -0
  164. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/current/dataflows/WT.yaml +0 -0
  165. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-03/codelists.yaml +0 -0
  166. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-03/dataflows.yaml +0 -0
  167. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-03/indicators.yaml +0 -0
  168. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-03/summary.yaml +0 -0
  169. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-05/_unicefdata_codelists.yaml +0 -0
  170. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-05/_unicefdata_countries.yaml +0 -0
  171. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-05/_unicefdata_dataflows.yaml +0 -0
  172. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-05/_unicefdata_indicators.yaml +0 -0
  173. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-05/_unicefdata_regions.yaml +0 -0
  174. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-05/summary.yaml +0 -0
  175. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-07/_unicefdata_codelists.yaml +0 -0
  176. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-07/_unicefdata_countries.yaml +0 -0
  177. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-07/_unicefdata_dataflows.yaml +0 -0
  178. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-07/_unicefdata_indicators.yaml +0 -0
  179. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-07/_unicefdata_regions.yaml +0 -0
  180. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2025-12-07/summary.yaml +0 -0
  181. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2026-01-21/_unicefdata_codelists.yaml +0 -0
  182. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2026-01-21/_unicefdata_countries.yaml +0 -0
  183. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2026-01-21/_unicefdata_dataflows.yaml +0 -0
  184. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2026-01-21/_unicefdata_indicators.yaml +0 -0
  185. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2026-01-21/_unicefdata_regions.yaml +0 -0
  186. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2026-01-21/summary.yaml +0 -0
  187. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2026-01-25/_unicefdata_codelists.yaml +0 -0
  188. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2026-01-25/_unicefdata_countries.yaml +0 -0
  189. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2026-01-25/_unicefdata_dataflows.yaml +0 -0
  190. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2026-01-25/_unicefdata_indicators.yaml +0 -0
  191. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2026-01-25/_unicefdata_regions.yaml +0 -0
  192. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata/vintages/2026-01-25/summary.yaml +0 -0
  193. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/metadata_manager.py +0 -0
  194. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/schema_cache.py +0 -0
  195. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/sdmx.py +0 -0
  196. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata/yaml_formatter.py +0 -0
  197. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata.egg-info/dependency_links.txt +0 -0
  198. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata.egg-info/requires.txt +0 -0
  199. {unicefdata-2.4.1 → unicefdata-3.0.0}/unicefdata.egg-info/top_level.txt +0 -0
@@ -0,0 +1,1383 @@
1
+ Metadata-Version: 2.4
2
+ Name: unicefdata
3
+ Version: 3.0.0
4
+ Summary: Python library for downloading UNICEF indicators via SDMX API
5
+ Author-email: Joao Pedro Azevedo <jpazevedo@unicef.org>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/unicef-drp/unicefData
8
+ Project-URL: Documentation, https://github.com/unicef-drp/unicefData/tree/main/python
9
+ Project-URL: Repository, https://github.com/unicef-drp/unicefData
10
+ Project-URL: Changelog, https://github.com/unicef-drp/unicefData/blob/main/python/CHANGELOG.md
11
+ Project-URL: Bug Tracker, https://github.com/unicef-drp/unicefData/issues
12
+ Keywords: unicef,sdmx,indicators,data,api,statistics,sdg,development
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Natural Language :: English
17
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Operating System :: OS Independent
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: requests>=2.28.0
28
+ Requires-Dist: pandas>=1.5.0
29
+ Requires-Dist: pyyaml>=6.0
30
+ Provides-Extra: excel
31
+ Requires-Dist: openpyxl>=3.0.0; extra == "excel"
32
+ Requires-Dist: xlrd>=2.0.0; extra == "excel"
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
35
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
36
+ Requires-Dist: responses>=0.23.0; extra == "dev"
37
+ Requires-Dist: black>=22.0.0; extra == "dev"
38
+ Requires-Dist: flake8>=5.0.0; extra == "dev"
39
+ Requires-Dist: mypy>=0.990; extra == "dev"
40
+ Dynamic: license-file
41
+
42
+ # unicefData - Python Package
43
+
44
+ [![PyPI version](https://badge.fury.io/py/unicefdata.svg)](https://pypi.org/project/unicefdata/)
45
+ [![Python Tests](https://github.com/unicef-drp/unicefData/actions/workflows/python-tests.yaml/badge.svg)](https://github.com/unicef-drp/unicefData/actions)
46
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
47
+ [![Downloads](https://static.pepy.tech/badge/unicefdata)](https://pepy.tech/project/unicefdata)
48
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
49
+
50
+ **Python component of the trilingual unicefData library for downloading UNICEF SDG indicators via SDMX API**
51
+
52
+ This is the Python implementation of the **unicefData** package. For other implementations, see the links below.
53
+
54
+ > **Other languages:** [R](https://github.com/unicef-drp/unicefData/blob/main/r/README.md) | [Stata](https://github.com/unicef-drp/unicefData/blob/main/stata/README.md) | [Main README](https://github.com/unicef-drp/unicefData/blob/main/README.md)
55
+
56
+ ---
57
+
58
+ ## Installation
59
+
60
+ ```bash
61
+ pip install unicefdata
62
+ ```
63
+
64
+ For development:
65
+
66
+ ```bash
67
+ git clone https://github.com/unicef-drp/unicefData.git
68
+ cd unicefData/python
69
+ pip install -e ".[dev]"
70
+ ```
71
+
72
+ ### Verify Installation
73
+
74
+ ```python
75
+ import unicefdata
76
+ print(unicefdata.__version__)
77
+ ```
78
+
79
+ ```
80
+ 3.0.0
81
+ ```
82
+
83
+ ---
84
+
85
+ ## What's New in 3.0.0
86
+
87
+ 3.0.0 is a major version: an unchanged call can return different rows. A
88
+ selected code that is not served now gives an empty frame (it gave every row),
89
+ `_T` is the default for every dimension where it is served, and a selection
90
+ that matches nothing no longer raises `SDMXNotFoundError`. See "Breaking
91
+ changes" in [CHANGELOG.md](https://github.com/unicef-drp/unicefData/blob/main/python/CHANGELOG.md) for what to change. R and Stata move
92
+ to 3.0.0 with the same rule.
93
+
94
+ - **One selection rule for every disaggregation**, the same in R and Stata.
95
+ `sex`, `age`, `wealth`/`wealth_quintile`, `residence`, `maternal_edu`,
96
+ `education_level` and `disability` each take one code, several (a list, or
97
+ one string split on `+`, spaces or commas; any case) or `"ALL"`:
98
+
99
+ ```python
100
+ unicefData("CME_MRY0T4", countries=["BGD"], wealth=["Q1", "Q5"]) # also "Q1+Q5", "q1, q5"
101
+ unicefData("CME_MRY0T4", countries=["BGD"], wealth="ALL") # Q1..Q5 and _T
102
+ ```
103
+
104
+ Codes not served are dropped with a warning listing the values served; if
105
+ none is served the result is empty, marked
106
+ `attrs["query_status"] = "filtered_to_empty"` (not "indicator not found").
107
+ - **The default is `_T` wherever it is served**, for every dimension,
108
+ whatever the indicator metadata says. Where `_T` is not served, age takes
109
+ the first of `Y0T4 Y0T14 Y0T17 Y15T49 ALLAGE`, disability `PD`, and any
110
+ other dimension keeps every value.
111
+ - **You are told when a default left values out**, and which:
112
+
113
+ ```
114
+ Note: CME_MRY0T4 - defaults applied; other values are available:
115
+ sex: _T (default); also F M
116
+ wealth: _T (default); also Q1 Q2 Q3 Q4 Q5
117
+ Select them with the option, e.g. sex="F", or "ALL" for every value.
118
+ ```
119
+
120
+ - **The indicator's metadata is shown after a download**, as Stata shows it:
121
+ the indicator, the dataflow that served it, name, description and number of
122
+ observations, then the RDM reference metadata (definition, sector, SDG
123
+ target, custodian, sources, and the first paragraph of why it matters,
124
+ concepts, computation method and limitations) and links to the full record.
125
+ `nometadata=True` keeps only the indicator, dataflow and observations;
126
+ `fullmetadata=True` prints every paragraph; `rdm_metadata=False` drops the
127
+ RDM part.
128
+ - **`format="wide_attributes"` works for indicators without age, residence
129
+ or maternal education** (it returned 0 rows), and
130
+ `attrs["retrieved_at"]` records when the data came back (UTC).
131
+ - **The error and edge paths match R and Stata.** An unknown country gives an
132
+ empty frame marked `attrs["query_status"] = "country_not_found"`, with a
133
+ warning (it raised "Indicator ... not found"); an indicator no dataflow
134
+ serves still raises `SDMXNotFoundError`. `raw=True` applies `countries` and
135
+ the selections you pass, and no default (it ignored both). Exact duplicate
136
+ rows are dropped with a warning (`keep_duplicates=True` keeps them; they
137
+ raised `ValueError`).
138
+ - **Country codes are checked against the shipped country and region
139
+ lists.** An unknown code is requested anyway and named in a warning; if none is known
140
+ and nothing comes back, `attrs["query_status"]` is `"country_unknown"`.
141
+ Output columns and options in Python, R and Stata, side by side: "Output
142
+ columns" in the [repository README](https://github.com/unicef-drp/unicefData/blob/main/README.md#output-columns).
143
+ - **The defaults note is a `DefaultsAppliedWarning`**, and `quiet=True`
144
+ prints nothing:
145
+
146
+ ```python
147
+ import warnings
148
+ from unicefdata import unicefData, DefaultsAppliedWarning
149
+
150
+ df = unicefData("CME_MRY0T4", countries=["BGD"], quiet=True) # silent
151
+ warnings.simplefilter("ignore", DefaultsAppliedWarning) # or just the note
152
+ ```
153
+
154
+ ## What's New in 2.11.0
155
+
156
+ - **Country aggregates, offline**: `list_aggregates(agency=, agg_type=)`,
157
+ `aggregate_members("UNICEF_LAC")` and `country_aggregates("BRA")` read the
158
+ shipped `_unicefdata_country_aggregates.yaml` (UNICEF DAPM's
159
+ Country-and-Region-Metadata ETL: UNICEF reporting and programme regions,
160
+ World Bank income levels and regions, WHO, UNSD M49 and SIDS / LDC / LLDC
161
+ lists, 155 aggregates from 11 agencies). Same functions in R and Stata.
162
+ - **`add_metadata` is data-driven**: `region`, `income_group` and
163
+ `continent` come from the store (embedded tables as fallback); new keys
164
+ `reporting_region`, `programme_region`, `wb_region`, `who_region`, `sids`,
165
+ `ldc`, `lldc`; every classification key also adds its `_code` companion
166
+ (`region_code`, `income_group_code`, ...). The 12 Caribbean small states no
167
+ longer map to `NaN`; Djibouti and Sudan move to Sub-Saharan Africa; 22
168
+ income reclassifications.
169
+ - **`countries=` accepts aggregate codes** (`UNICEF_SSA`, `WB_LMI`, ...) and
170
+ **`geo_type` tags every aggregate the warehouse serves**.
171
+ - **`sync_country_aggregates()`** / `python -m unicefdata.crm_client` refresh
172
+ the store and mirror it into the R and Stata trees.
173
+
174
+ ## What's New in 2.9.0
175
+
176
+ - **Indicator cards**: `get_indicator_card(code)` returns everything the package
177
+ knows about one indicator — definition, numerator/denominator, method of
178
+ computation, unit, sector and domain, SDG target, custodian, data sources,
179
+ tags, related indicators, serving dataflows and the dimensions you can
180
+ disaggregate by — assembled offline from the shipped metadata, so it costs no
181
+ network call. `info(code)` prints it at your terminal's width; `full=True`
182
+ adds the long-form narrative and the link URLs.
183
+ - **Card export**: `card_export(card, "card.yaml")` — or `card.json` — writes
184
+ the card to a byte-reproducible document; the format follows the extension,
185
+ `format=` overrides it. R and Stata emit the same document, field for field.
186
+ - **Reference-metadata search**: `search_indicators(query=, sdg=, sector=,
187
+ custodian=, tag=, flags=, type=, dataflow=)`, composable, over the same
188
+ 738-indicator card store R and Stata search — so the three languages return
189
+ identical cards, dimension code lists and result sets.
190
+ - **`info()` never dead-ends**: a code known to *either* upstream source now
191
+ renders a card that states which half is missing, instead of raising. The
192
+ unpublished `SP_*` indicators that published cards link to as *related* ship
193
+ in a new `_unicefdata_rdm_reference_only.yaml`, so every link the package
194
+ renders resolves offline.
195
+ - **`dataflow=` search filter**: `search_indicators(dataflow="CME")` filters on
196
+ dataflow **membership** (an indicator belongs to several), AND-composing with
197
+ every other filter.
198
+ - **Raw RDM record download**: `rdm_record(code, saving="rec.json")` — export
199
+ path A, "what RDM says", live and verbatim. Distinct from
200
+ `describe_indicator(code, save=...)`, which is path B, "what unicefData
201
+ knows": the offline, normalised, vintage-stamped card.
202
+
203
+ ## What's New in 2.4.2
204
+
205
+ - **Localization fix**: Added `Accept-Language: en` to all SDMX API requests —
206
+ prevents occasional non-English indicator names returned by the UNICEF API
207
+ when no locale is specified (fixes [#45](https://github.com/unicef-drp/unicefData/issues/45))
208
+
209
+ ## What's New in 2.4.1
210
+
211
+ - **`diagnose` parameter**: New opt-in `diagnose=True` for `unicefData()`. Default behavior restored to server-side year filtering (faster). Query status codes only populated when `diagnose=True`.
212
+ - Version alignment: v2.4.0 was tagged before R/Stata `diagnose` landed.
213
+
214
+ ## What's New in 2.4.0
215
+
216
+ - **Query status codes**: Empty results now tell you *why* via `df.attrs["query_status"]`:
217
+ - `year_not_found` — country has data, but not for the requested year (gap in time series)
218
+ - `year_beyond_range` — requested year is before the earliest or after the latest data point
219
+ - `country_not_found` — indicator exists but not for this country (includes `available_countries`)
220
+ - `indicator_not_found` — indicator doesn't exist in any dataflow
221
+ - **Client-side year filtering**: Fixes 6 survey-based indicators (NUTRITION, MNCH, EDUCATION) that failed with year filters due to an SDMX API quirk
222
+ - **Smarter fallback logic**: No longer wastes API calls trying non-existent fallback dataflows when data simply doesn't exist for the requested country/year
223
+
224
+ ```python
225
+ df = unicefData("MNCH_CSEC", countries=["BRA"], year=2020, diagnose=True)
226
+ # len(df) == 0
227
+ print(df.attrs["query_status"]) # "year_beyond_range"
228
+ print(df.attrs["available_years"]) # [2000, 2001, ..., 2019]
229
+ print(df.attrs["nearest_year"]) # 2019
230
+ ```
231
+
232
+ ## What's New in 2.2.2
233
+
234
+ - **`UNICEFSDMXClient` dataflow resolution fixed**: `fetch_indicator()` now auto-detects the correct dataflow from metadata instead of always defaulting to `GLOBAL_DATAFLOW`, consistent with `unicefData()`
235
+
236
+ ## What's New in 2.2.1
237
+
238
+ - **Bundled metadata paths corrected**: Startup warnings about missing fallback sequences and indicators metadata are resolved
239
+ - **Codelists filename fixed**: `MetadataManager` now correctly loads `_unicefdata_codelists.yaml`
240
+ - **Category lookup fixed**: `list_categories()` and `search_indicators(category=...)` now return correct results instead of all `UNKNOWN`
241
+
242
+ See [CHANGELOG.md](https://github.com/unicef-drp/unicefData/blob/main/python/CHANGELOG.md) for complete details.
243
+
244
+ ## What's New in 2.2.0
245
+
246
+ - **328+ automated tests** across 11 test families with deterministic fixtures
247
+ - **Full CI matrix**: Python 3.9–3.12 on Ubuntu / macOS / Windows
248
+ - **Bug fixes**: Sex filter for full-dataflow, None indicator handling, retry logic
249
+ - **Input validation**: Filters empty/whitespace indicators with helpful error messages
250
+
251
+ ---
252
+
253
+ ## Quick Start
254
+
255
+ ### Search for Indicators
256
+
257
+ ```python
258
+ from unicefdata import search_indicators, list_categories
259
+
260
+ # List all categories
261
+ list_categories()
262
+ ```
263
+
264
+ ```
265
+ ==================================================
266
+ Available Indicator Categories
267
+ ==================================================
268
+
269
+ CATEGORY COUNT
270
+ --------------------------------------------------
271
+ NUTRITION 112
272
+ CAUSE_OF_DEATH 83
273
+ CHILD_RELATED_SDG 77
274
+ WASH_HOUSEHOLDS 64
275
+ EDUCATION_UIS_SDG 62
276
+ PT 52
277
+ GLOBAL_DATAFLOW 50
278
+ CHLD_PVTY 43
279
+ CME 39
280
+ HIV_AIDS 38
281
+ MNCH 38
282
+ DM 31
283
+ MG 26
284
+ IMMUNISATION 18
285
+ GENDER 16
286
+ ECON 13
287
+ FUNCTIONAL_DIFF 12
288
+ SOC_PROTECTION 10
289
+ ECD 8
290
+ --------------------------------------------------
291
+ TOTAL 792
292
+
293
+ Use search_indicators(category='CATEGORY_NAME') to see indicators
294
+ ```
295
+
296
+ ```python
297
+ # Search by keyword
298
+ search_indicators("mortality")
299
+ ```
300
+
301
+ ```
302
+ ====================================================================================================
303
+ UNICEF Indicators matching 'mortality'
304
+ ====================================================================================================
305
+
306
+ Found 24 indicator(s)
307
+ ----------------------------------------------------------------------------------------------------
308
+ CODE CATEGORY NAME DESCRIPTION
309
+ ----------------------------------------------------------------------------------------------------
310
+ CME_MRM0 CME Neonatal mortality rate Probability of d..
311
+ CME_MRY0 CME Infant mortality rate Probability of d..
312
+ CME_MRY0T4 CME Under-five mortality rate Probability of d..
313
+ CME_MRY5T14 CME Mortality rate (children aged 5 t.. Probability of d..
314
+ MNCH_MMR MNCH Maternal mortality ratio (number .. Maternal mortali..
315
+ ...
316
+ ----------------------------------------------------------------------------------------------------
317
+ Usage tips:
318
+ - unicefData(indicator='CODE') to fetch data for an indicator
319
+ - search_indicators(category='CME') to browse by category
320
+ ```
321
+
322
+ ```python
323
+ # Search within a category
324
+ search_indicators(category="CME")
325
+ search_indicators("rate", category="CME")
326
+ ```
327
+
328
+ ---
329
+
330
+ ### Download Data
331
+
332
+ ```python
333
+ from unicefdata import unicefData
334
+
335
+ # Fetch under-5 mortality rate (dataflow auto-detected)
336
+ df = unicefData(
337
+ indicator="CME_MRY0T4",
338
+ countries=["ALB", "USA", "BRA"],
339
+ year="2015:2023" # range, single year, or list
340
+ )
341
+
342
+ print(df.shape)
343
+ print(df[["iso3", "country", "period", "indicator", "value"]].to_string(index=False))
344
+ ```
345
+
346
+ ```
347
+ (27, 21)
348
+
349
+ iso3 country period indicator value
350
+ ALB Albania 2015.0 CME_MRY0T4 9.586263
351
+ ALB Albania 2016.0 CME_MRY0T4 9.400753
352
+ ALB Albania 2017.0 CME_MRY0T4 9.336307
353
+ ALB Albania 2018.0 CME_MRY0T4 9.344314
354
+ ALB Albania 2019.0 CME_MRY0T4 9.386670
355
+ ALB Albania 2020.0 CME_MRY0T4 9.435272
356
+ ALB Albania 2021.0 CME_MRY0T4 9.456832
357
+ ALB Albania 2022.0 CME_MRY0T4 9.436385
358
+ ALB Albania 2023.0 CME_MRY0T4 9.357239
359
+ BRA Brazil 2015.0 CME_MRY0T4 15.963330
360
+ BRA Brazil 2016.0 CME_MRY0T4 16.771457
361
+ ...
362
+ USA United States 2023.0 CME_MRY0T4 6.482592
363
+ ```
364
+
365
+ ```python
366
+ # Summary statistics
367
+ print(df["value"].describe().round(2))
368
+ ```
369
+
370
+ ```
371
+ count 27.00
372
+ mean 10.40
373
+ std 3.70
374
+ min 6.46
375
+ 25% 6.64
376
+ 50% 9.40
377
+ 75% 14.66
378
+ max 16.77
379
+ Name: value, dtype: float64
380
+ ```
381
+
382
+ ```python
383
+ # Cross-country pivot table (countries × years)
384
+ print(df.groupby(["iso3", "period"])["value"].first().unstack().round(1))
385
+ ```
386
+
387
+ ```
388
+ period 2015.0 2016.0 2017.0 2018.0 2019.0 2020.0 2021.0 2022.0 2023.0
389
+ iso3
390
+ ALB 9.6 9.4 9.3 9.3 9.4 9.4 9.5 9.4 9.4
391
+ BRA 16.0 16.8 15.4 15.2 15.0 14.9 14.7 14.6 14.4
392
+ USA 6.8 6.7 6.6 6.5 6.5 6.5 6.5 6.5 6.5
393
+ ```
394
+
395
+ ---
396
+
397
+ ### View Dataflow Schema
398
+
399
+ ```python
400
+ from unicefdata import dataflow_schema, print_dataflow_schema
401
+
402
+ print_dataflow_schema(dataflow_schema("CME"))
403
+ ```
404
+
405
+ ```
406
+ ----------------------------------------------------------------------
407
+ Dataflow Schema: CME
408
+ ----------------------------------------------------------------------
409
+
410
+ Name: Child Mortality
411
+ Version: 1.0
412
+ Agency: UNICEF
413
+
414
+ Dimensions (4):
415
+ REF_AREA
416
+ INDICATOR
417
+ SEX
418
+ WEALTH_QUINTILE
419
+
420
+ Attributes (7):
421
+ DATA_SOURCE
422
+ COUNTRY_NOTES
423
+ REF_PERIOD
424
+ UNIT_MEASURE
425
+ LOWER_BOUND
426
+ UPPER_BOUND
427
+ OBS_STATUS
428
+ ----------------------------------------------------------------------
429
+ ```
430
+
431
+ ---
432
+
433
+ ## Post-Production Options
434
+
435
+ ### Output Formats
436
+
437
+ ```python
438
+ # Long format (default) — one row per country × year
439
+ df = unicefData(indicator="CME_MRY0T4", countries=["ALB", "USA", "BRA"],
440
+ year="2020:2022", format="long")
441
+ print(df[["iso3", "country", "period", "value"]].to_string(index=False))
442
+ ```
443
+
444
+ ```
445
+ iso3 country period value
446
+ ALB Albania 2020.0 9.435272
447
+ ALB Albania 2021.0 9.456832
448
+ ALB Albania 2022.0 9.436385
449
+ BRA Brazil 2020.0 14.873612
450
+ BRA Brazil 2021.0 14.723535
451
+ BRA Brazil 2022.0 14.588250
452
+ USA United States 2020.0 6.469871
453
+ USA United States 2021.0 6.464968
454
+ USA United States 2022.0 6.473319
455
+ ```
456
+
457
+ ```python
458
+ # Wide format — years as columns
459
+ df = unicefData(indicator="CME_MRY0T4", countries=["ALB", "USA", "BRA"],
460
+ year="2020:2022", format="wide")
461
+ print(df[["iso3", "country", 2020.0, 2021.0, 2022.0]].to_string(index=False))
462
+ ```
463
+
464
+ ```
465
+ iso3 country 2020.0 2021.0 2022.0
466
+ ALB Albania 9.435272 9.456832 9.436385
467
+ BRA Brazil 14.873612 14.723535 14.588250
468
+ USA United States 6.469871 6.464968 6.473319
469
+ ```
470
+
471
+ ```python
472
+ # Wide indicators — indicators as columns
473
+ df = unicefData(
474
+ indicator=["CME_MRY0T4", "CME_MRM0"],
475
+ countries=["ALB", "USA", "BRA"],
476
+ year="2020:2022",
477
+ format="wide_indicators"
478
+ )
479
+ print(df[["iso3", "country", "period", "CME_MRY0T4", "CME_MRM0"]].to_string(index=False))
480
+ ```
481
+
482
+ ```
483
+ iso3 country period CME_MRY0T4 CME_MRM0
484
+ ALB Albania 2020.0 9.435272 7.185830
485
+ ALB Albania 2021.0 9.456832 7.125219
486
+ ALB Albania 2022.0 9.436385 6.998704
487
+ BRA Brazil 2020.0 14.873612 9.163120
488
+ BRA Brazil 2021.0 14.723535 8.893245
489
+ BRA Brazil 2022.0 14.588250 8.281859
490
+ USA United States 2020.0 6.469871 3.642096
491
+ USA United States 2021.0 6.464968 3.520667
492
+ USA United States 2022.0 6.473319 3.477007
493
+ ```
494
+
495
+ ---
496
+
497
+ ### Latest Value Per Country
498
+
499
+ ```python
500
+ df = unicefData(
501
+ indicator="CME_MRY0T4",
502
+ countries=["ALB", "BRA", "DEU", "IND", "USA"],
503
+ latest=True
504
+ )
505
+ print(df[["iso3", "country", "period", "value"]].to_string(index=False))
506
+ ```
507
+
508
+ ```
509
+ iso3 country period value
510
+ ALB Albania 2024.0 9.227080
511
+ BRA Brazil 2024.0 14.216972
512
+ DEU Germany 2024.0 3.711222
513
+ IND India 2024.0 26.579900
514
+ USA United States 2024.0 6.472463
515
+ ```
516
+
517
+ ---
518
+
519
+ ### Most Recent Values (MRV)
520
+
521
+ ```python
522
+ df = unicefData(indicator="CME_MRY0T4", countries=["ALB", "USA", "BRA"], mrv=3)
523
+ print(df[["iso3", "country", "period", "value"]].sort_values(["iso3", "period"]).to_string(index=False))
524
+ ```
525
+
526
+ ```
527
+ iso3 country period value
528
+ ALB Albania 2022.0 9.436385
529
+ ALB Albania 2023.0 9.357239
530
+ ALB Albania 2024.0 9.227080
531
+ BRA Brazil 2022.0 14.588250
532
+ BRA Brazil 2023.0 14.424723
533
+ BRA Brazil 2024.0 14.216972
534
+ USA United States 2022.0 6.473319
535
+ USA United States 2023.0 6.482592
536
+ USA United States 2024.0 6.472463
537
+ ```
538
+
539
+ ---
540
+
541
+ ### Circa (Nearest Year)
542
+
543
+ For each series (a country and its sex, age, wealth, ... values) the observation nearest the year; every year is requested, a tie goes to the earlier year, and rows with no value are skipped. The same rule in Python, R and Stata: see [circa: the nearest year](https://github.com/unicef-drp/unicefData/blob/main/README.md#circa-the-nearest-year).
544
+
545
+ ```python
546
+ # Returns the closest available observation to the target year
547
+ df = unicefData(
548
+ indicator="CME_MRY0T4",
549
+ countries=["ALB", "USA", "BRA"],
550
+ year=2015,
551
+ circa=True
552
+ )
553
+ print(df[["iso3", "country", "period", "value"]].to_string(index=False))
554
+ ```
555
+
556
+ ```
557
+ iso3 country period value
558
+ ALB Albania 2015.0 9.586263
559
+ BRA Brazil 2015.0 15.963330
560
+ USA United States 2015.0 6.752855
561
+ ```
562
+
563
+ ---
564
+
565
+ ### Add Metadata
566
+
567
+ ```python
568
+ df = unicefData(
569
+ indicator="CME_MRY0T4",
570
+ countries=["ALB", "BRA", "IND", "NGA", "USA"],
571
+ latest=True,
572
+ add_metadata=["region", "income_group"]
573
+ )
574
+ print(df[["iso3", "country", "period", "value", "region", "income_group"]].to_string(index=False))
575
+ ```
576
+
577
+ ```
578
+ iso3 country period value region income_group
579
+ ALB Albania 2024.0 9.227080 Europe and Central Asia Upper middle income
580
+ BRA Brazil 2024.0 14.216972 Latin America and Caribbean Upper middle income
581
+ IND India 2024.0 26.579900 South Asia Lower middle income
582
+ NGA Nigeria 2024.0 115.649434 Sub-Saharan Africa Lower middle income
583
+ USA United States 2024.0 6.472463 North America High income
584
+ ```
585
+
586
+ ```python
587
+ # Frequency table by income group
588
+ print(df.groupby("income_group")["value"].agg(["count", "mean", "min", "max"]).round(2))
589
+ ```
590
+
591
+ ```
592
+ count mean min max
593
+ income_group
594
+ High income 1 6.47 6.47 6.47
595
+ Lower middle income 2 71.11 26.58 115.65
596
+ Upper middle income 2 11.72 9.23 14.22
597
+ ```
598
+
599
+ All country-level keys come offline from the shipped country-aggregates store
600
+ (see the next section) and are missing on aggregate rows. Every classification
601
+ key adds two columns, the label and its `_code` companion:
602
+
603
+ | Key | Columns | Source |
604
+ |-----|---------|--------|
605
+ | `region` (alias `reporting_region`) | `region`, `region_code` - UNICEF reporting region, top level (EAP, ECA, LAC, MENA, NA, SA, SSA) | UNICEF SDMX hierarchy via the ETL |
606
+ | `programme_region` | `programme_region`, `programme_region_code` - UNICEF regional office (EAPRO, ECARO, ESARO, LACRO, MENARO, ROSA, WCARO) | same |
607
+ | `income_group` | `income_group`, `income_group_code` - World Bank income level, current classification | World Bank via the ETL |
608
+ | `continent` | `continent` - six continents recomposed from UNSD M49 regions (no single code) | UNSD via the ETL |
609
+ | `wb_region`, `who_region` | label + `_code` - World Bank region, WHO region | same |
610
+ | `sids`, `ldc`, `lldc` | `True`/`False` UNSD list flags | UNSD via the ETL |
611
+
612
+ ### Country Aggregates (offline)
613
+
614
+ ```python
615
+ from unicefdata import list_aggregates, aggregate_members, country_aggregates
616
+
617
+ aggregate_members("UNICEF_LAC") # ['AIA', 'ARG', 'ATG', ..., 'VGB'] (37)
618
+ country_aggregates("BRA") # one row per membership: UNICEF_LAC, UNICEF_LACRO, WB_UMI, WHO_AMRO, ...
619
+ list_aggregates(agency="UNICEF", agg_type="UNICEF_REP_REG_GLOBAL")
620
+ # code, agency, type, name, label, parent, n_members
621
+ ```
622
+
623
+ Hierarchy roots (`UNICEF_REPORTING_REGIONS`, `UNICEF_PROGRAMME_REGIONS`) are
624
+ dropped at sync time; nesting is exposed as `parent` (`UNICEF_ESA` inside
625
+ `UNICEF_SSA`). The warehouse publishes regional *values* under these codes, so
626
+ they are valid in `countries=`:
627
+
628
+ ```python
629
+ df = unicefData(indicator="CME_MRY0T4", countries=["UNICEF_SSA", "UNICEF_WCA", "BRA"], year=2023)
630
+ df[["iso3", "geo_type", "value"]] # the regional rows carry geo_type == 1
631
+ ```
632
+
633
+ Refresh the store (and mirror it into the R and Stata trees) with
634
+ `python -m unicefdata.crm_client`; `--report` prints how it differs from the
635
+ embedded tables.
636
+
637
+ ---
638
+
639
+ ### Metadata Enrichment (RDM)
640
+
641
+ Indicator reference metadata from UNICEF's [Reference Data Manager](https://rdmapi.unicef.org)
642
+ ships with the package and is resolved offline — no extra API calls at query time.
643
+
644
+ **On by default:** every successful fetch attaches the RDM reference record for
645
+ each queried indicator as `df.attrs["rdm_metadata"]` — a dict keyed by
646
+ indicator code with (when available) `definition`, `sector`, `domain`,
647
+ `custodian`, `data_sources`, `sdg_target`, the classification flags/keys
648
+ `is_sdg`, `sp_indicator`, `is_countdown2030`, and `is_unicef_custodian`, plus
649
+ the long-form `rationale`, `concepts`, `computation_method`, and
650
+ `limitations` texts. The long-form values keep paragraph boundaries as `"\n\n"`
651
+ separators. Pass `rdm_metadata=False` to opt out:
652
+
653
+ ```python
654
+ df = unicefData(indicator="CME_MRY0T4", countries=["BRA"], latest=True)
655
+ df.attrs["rdm_metadata"]["CME_MRY0T4"]["sector"] # 'Child mortality'
656
+ df.attrs["rdm_metadata"]["CME_MRY0T4"]["limitations"].split("\n\n")[0] # first paragraph
657
+
658
+ df = unicefData(indicator="CME_MRY0T4", countries=["BRA"], rdm_metadata=False)
659
+ "rdm_metadata" in df.attrs # False
660
+ ```
661
+
662
+ Indicators without an RDM record simply do not appear in the dict, and empty
663
+ results carry no attrs — never an error. Note that pandas `attrs` are
664
+ experimental and may not survive every DataFrame operation (`concat`/`merge`
665
+ can drop them); `describe_indicator()` re-derives the record at any time.
666
+
667
+ **Metadata columns stay opt-in** via `add_metadata=`:
668
+
669
+ ```python
670
+ df = unicefData(
671
+ indicator="CME_MRY0T4",
672
+ countries=["BRA"],
673
+ latest=True,
674
+ add_metadata="rdm", # = ["definition", "sector", "domain", "custodian", "data_sources"]
675
+ )
676
+ print(df[["iso3", "period", "value", "sector", "definition"]].to_string(index=False))
677
+
678
+ # Individual options combine with the existing ones;
679
+ # "sdg" adds a boolean is_sdg column
680
+ df = unicefData(
681
+ indicator="CME_MRY0T4",
682
+ countries=["BRA"],
683
+ latest=True,
684
+ add_metadata=["region", "definition", "sdg"],
685
+ )
686
+
687
+ # Full record including long-form texts (rationale, limitations, computation method)
688
+ from unicefdata import describe_indicator
689
+ info = describe_indicator("CME_MRY0T4") # prints the record, returns it as a dict
690
+ info = describe_indicator("CME_MRY0T4", verbose=False) # the dict only
691
+ print(info["definition"])
692
+ print(info["rationale"])
693
+ ```
694
+
695
+ Indicators without an RDM record (about 25% of the registry, e.g. `COD_*`
696
+ cause-of-death series) get `NaN` in the enrichment columns, and
697
+ `describe_indicator()` returns a dict with a `message` key instead of failing.
698
+
699
+ ---
700
+
701
+ ### Indicator Cards: `get_indicator_card()`, `info()`, search and export
702
+
703
+ Everything the package knows about an indicator is assembled **offline** into
704
+ one *card* — the same field set in Python, R and Stata, so a card built here
705
+ equals the card built there:
706
+
707
+ ```python
708
+ from unicefdata import get_indicator_card
709
+
710
+ card = get_indicator_card("CME_MRY0T4")
711
+ card["identity"]["name"] # 'Under-five mortality rate'
712
+ card["classification"]["sdg_target"] # '3.2.1'
713
+ card["long_form"]["limitations"].split("\n\n")[0] # first paragraph
714
+ card["dims"][0] # {'dimension': 'SEX', 'codes': [...]}
715
+ card["provenance"]["citation"] # one-line citation with the vintage
716
+ ```
717
+
718
+ | Section | Keys |
719
+ |---------|------|
720
+ | *(top level)* | `code`, `found` (always); `message` when unknown or without an RDM record |
721
+ | `identity` | `code`, `name`, `category`, `dataflows` (list), `found`, `has_rdm`, `has_details` |
722
+ | `reference` | `definition`, `numerator`, `denominator`, `additional_details`, `aggregation_method`, `aggregation_population` |
723
+ | `long_form` | `rationale`, `concepts`, `computation_method`, `limitations`, `sdg_progress_methodology` (paragraphs kept as `"\n\n"`) |
724
+ | `taxonomy` | `sector`, `domain`, `subdomain`, `indicator_type`, `custodian`, `co_custodians`, `data_sources`, `tags` (last three are lists) |
725
+ | `classification` | `sdg_target`, `sp_indicator`, `is_sdg`, `is_sowc`, `is_covid`, `is_emergency`, `is_countdown2030`, `is_unicef_custodian` |
726
+ | `related` | list of `{code, name}` |
727
+ | `dims` | list of `{dimension, codes, names}` |
728
+ | `links` | `urn`, `api_query`, `rdm_record` |
729
+ | `provenance` | `rdm_id`, `rdm_published`, `metadata_vintage`, `source`, `retrieved`, `citation` |
730
+
731
+ Keys with no value are omitted; unknown codes return
732
+ `{"code": ..., "found": False, "message": ...}` — the accessor never raises.
733
+ `describe_indicator()` is the flat view over the same card and keeps its
734
+ historical keys.
735
+
736
+ **`info()` prints the card** (the layout Stata's `unicefdata, info()` renders,
737
+ wrapped at 78 columns) and returns the card dict:
738
+
739
+ ```python
740
+ from unicefdata import info
741
+
742
+ card = info("CME_MRY0T4") # first paragraph of each long section
743
+ card = info("CME_MRY0T4", full=True) # every paragraph (and the link URLs)
744
+ card = info("CME_MRY0T4", quiet=True) # no printing, just the card
745
+ card = info("CME_MRY0T4", width=110) # default: the terminal's own width
746
+ ```
747
+
748
+ ```
749
+ ------------------------------------------------------------------------------
750
+ CME_MRY0T4 — Under-five mortality rate SDG 3.2.1
751
+ ------------------------------------------------------------------------------
752
+ Definition Probability of dying between birth and exactly 5 years of age,
753
+ expressed per 1,000 live births
754
+ Sector Child mortality · Type: Impact
755
+ Flags SDG x SOWC - COVID - Emergency -
756
+ Dataflow CME, GLOBAL_DATAFLOW
757
+ Disaggreg. SEX (F M _T) · WEALTH_QUINTILE (Q1 Q2 Q3 Q4 Q5 _T)
758
+ Related (26) SP_NUM_CEF · MNCH_ANC4 · MNCH_SAB · MNCH_PNCNB · +22 more
759
+ Links methodology & limitations · RDM record · API query
760
+ ------------------------------------------------------------------------------
761
+ Indicator details full text: full=True
762
+ ------------------------------------------------------------------------------
763
+ Why it matters
764
+ Mortality rates among young children are a key output indicator
765
+ for child health and well-being, and, more broadly, for ...
766
+ Concepts
767
+ The under-five mortality rate as defined here is, strictly
768
+ speaking, not a rate (i.e. the number of deaths divided by ...
769
+ Computation method (paragraph 1 of 5)
770
+ The UN Inter-agency Group for Child Mortality Estimation (UN
771
+ IGME) estimates are derived from national data from ...
772
+ Limitations (paragraph 1 of 2)
773
+ The UN IGME estimates are derived based on national data.
774
+ Countries often use a single source as their official ...
775
+ ------------------------------------------------------------------------------
776
+ Fetch: unicefData(indicator="CME_MRY0T4")
777
+ ------------------------------------------------------------------------------
778
+ ```
779
+
780
+ Layout notes (identical in Python, R and Stata):
781
+
782
+ * **one gutter** — labels at column 2, every value *and* every narrative body
783
+ at column 15;
784
+ * **one width** — the card is drawn at the terminal's width (clamped to
785
+ 40...255), exactly as the Stata card tracks `c(linesize)`; pass `width=` to
786
+ fix it. **No rendered line ever exceeds it**, which is why the `Links` row
787
+ carries labels rather than URLs: a printed API query is 102 characters and
788
+ used to punch straight through the rule. `full=True` lists the URLs
789
+ underneath, on the gutter;
790
+ * **facts first** — `Disaggreg.`, `Related` and `Links` sit in the facts block,
791
+ so the `Indicator details` tail is uninterrupted prose;
792
+ * `Related (N)` counts **distinct** codes (RDM repeats some), shows the first
793
+ four and tallies the rest as `+K more`;
794
+ * `full=True` is named once, in the `Indicator details` header; the per-section
795
+ annotation is just `(paragraph 1 of N)` and appears only when `N > 1`;
796
+ * an indicator with no long-form record (661 of the 738 registry codes — only
797
+ 77 carry any of the four narrative sections) simply ends after the facts
798
+ rule — no empty `Indicator details` header.
799
+
800
+ **Search runs over the card store**, offline. `search_indicators()` still prints
801
+ its table and now also returns a DataFrame (`code`, `name`, `sector`,
802
+ `indicator_type`, `sdg_target`, `match`), where `match` names the field the free
803
+ text hit:
804
+
805
+ ```python
806
+ from unicefdata import search_indicators
807
+
808
+ search_indicators("life table", quiet=True) # matches CME_MRY0T4 via concepts
809
+ search_indicators(type="Impact", sdg="3.2") # filters AND-compose
810
+ search_indicators(flags=["sowc", "emergency"]) # flags OR within the list
811
+ search_indicators(sector="child mortality", custodian="UNICEF", tag="mortality")
812
+ search_indicators("stunting", fields=["definition", "limitations"])
813
+ search_indicators(dataflow="CME") # dataflow MEMBERSHIP
814
+ search_indicators(dataflow="CME", sdg="3") # AND-composed with the rest
815
+ ```
816
+
817
+ `dataflow=` matches an indicator's **dataflow membership**, exactly on the
818
+ dataflow id and case-insensitively: `CME_MRY0T4` is carried by both `CME` and
819
+ `GLOBAL_DATAFLOW`, so either finds it. It is deliberately *not* `category=`,
820
+ which is the single organisational label the package assigns a code. Whole ids
821
+ only — `dataflow="CME"` never matches `CME_DF_2021_WQ`.
822
+
823
+ **`sdg=` addresses three digit levels with one option** — goal, target and
824
+ indicator — because it is a prefix match that stops on a target boundary:
825
+
826
+ | Call | Level | Matches |
827
+ |---|---|---|
828
+ | `search_indicators(sdg="3")` | goal | every Goal-3 target |
829
+ | `search_indicators(sdg="3.2")` | target | `3.2.1` and `3.2.2` |
830
+ | `search_indicators(sdg="3.2.1")` | indicator | that one target |
831
+ | `search_indicators(sdg="2.2.2a")` | lettered target | its own level only — `sdg="2.2.2"` is a *different* target and does not reach it |
832
+
833
+ The boundary rule is what keeps `sdg="1"` inside Goal 1 instead of sweeping up
834
+ `16.2.1`. Pass `limit=0` for a complete count: `limit` defaults to 50 and
835
+ truncates the returned frame.
836
+
837
+ Free text searches `code`, `name`, `definition`, `rationale`, `concepts`,
838
+ `computation_method`, `limitations` and `tags` (restrict with `fields=`).
839
+ `sdg=` is a prefix match that stops at a **target boundary** — the character
840
+ after the prefix must be a `.` or the end of the target, so `sdg="3.2"` →
841
+ `3.2.1` + `3.2.2`, `sdg="3"` → all of Goal 3, and `sdg="1"` never reaches
842
+ `16.2.1`. `flags=` accepts names with or without the `is_` prefix; a `flags=`
843
+ value that names no known flag matches **nothing** and the unrecognised names
844
+ are printed and returned on `result.attrs['flags_unknown']`. `limit=0`
845
+ (or `None`) means no cap.
846
+
847
+ Two rules hold for **every** filter, in all three languages. First, a
848
+ **supplied** filter that normalises to nothing — `sector=" "`, `type=" "`,
849
+ `sdg="."`, `flags=["nonsense"]` — matches **zero** rows: a filter is never
850
+ silently dropped, and never degrades into "substring of the empty string",
851
+ which returned the whole store. Only an absent value (`None`, `""`, `[]`, a
852
+ list of empty strings) is "no filter", and an empty element never disarms a
853
+ list filter: `flags=["", "sowc"]` filters on `sowc`. Second, all matching is
854
+ case-insensitive but every code comes back in the store's **own spelling** —
855
+ the registry has mixed-case keys (`TRGT_2030_PV_CHLD_AllPOP_NATPOVL`), and
856
+ `get_indicator_card("trgt_2030_pv_chld_allpop_natpovl")['code']` returns that
857
+ spelling — so the three languages agree on the result *strings*, not just on
858
+ the rows.
859
+
860
+ **Cross-language parity — precisely.** The searched universe is the shipped
861
+ card store (`_unicefdata_indicators.yaml`), byte-identical in the Python, R and
862
+ Stata trees, and the filter semantics are the same in all three, so the **set
863
+ of matching codes is identical** for the same query in `search_indicators()`,
864
+ R `unicefSearch()` and Stata `unicefdata search`. Every hit therefore has a
865
+ card that resolves (`get_indicator_card(code)['found'] is True`); codes that
866
+ exist only in the wider SDMX codelist (the `HAZARD` / `CLIMATE_*` hazard-layer
867
+ family) are deliberately out of reach. What is *not* identical: the return
868
+ type and printing (DataFrame + printed table here, tibble in R, SMCL table +
869
+ `r()` in Stata) and the result *order* (here: category then code; R: code;
870
+ Stata: registry-file order).
871
+
872
+ **Export a card as a standalone YAML** — the full card, real paragraphs, with a
873
+ provenance header (`generated_by`, `content_type`, `code`, `metadata_vintage`,
874
+ `rdm_record`, `api_query`, and `generated_at` only when you pass one, so exports
875
+ stay reproducible):
876
+
877
+ ```python
878
+ describe_indicator("CME_MRY0T4", save="CME_MRY0T4.yaml")
879
+
880
+ # or straight from a card
881
+ from unicefdata import card_to_yaml, get_indicator_card
882
+ card_to_yaml(get_indicator_card("CME_MRY0T4"), "CME_MRY0T4.yaml",
883
+ generated_at="2026-08-17T00:00:00Z")
884
+ ```
885
+
886
+ Exporting an **unknown** code raises `KeyError` and writes nothing — the same
887
+ contract in the three languages (R `stop()`s, Stata exits 111), because a
888
+ `found: false` document is not a card. `get_indicator_card()` and
889
+ `describe_indicator()` without `save=` still degrade gracefully and return a
890
+ `message` instead of raising.
891
+
892
+ #### Two export paths — do not conflate them
893
+
894
+ "Export" covers two different artifacts. They answer different questions and
895
+ have different dependency profiles:
896
+
897
+ | | **A — what RDM says** | **B — what unicefData knows** |
898
+ |---|---|---|
899
+ | Call | `rdm_record(code, saving="rec.json")` | `describe_indicator(code, save="card.yaml")` |
900
+ | Content | the record RDM *serves*, verbatim — every attribute, all nested objects, unnormalised | the assembled **card**: normalised, identical field names in Python/R/Stata, paragraphs preserved, provenance block |
901
+ | Network | **required** (live) | none (offline, from the shipped store) |
902
+ | Use it for | audit and provenance: diff against upstream, hand the raw record to a partner | reproducible analysis: vintage-stamped, cross-language identical, the factsheet's input |
903
+ | Stata | `unicefdata rdmrecord, indicator(CODE) saving(f.json)` | `unicefdata describe, indicator(CODE) saving(f.yaml)` |
904
+ | R | `unicefRdmRecord(code, file = "rec.json")` | `unicefDescribe(code, file = "card.yaml")` |
905
+
906
+ ```python
907
+ from unicefdata import rdm_record
908
+
909
+ record = rdm_record("CME_MRY0T4") # returns the dict
910
+ rdm_record("CME_MRY0T4", saving="CME_MRY0T4.json") # verbatim JSON
911
+ rdm_record("CME_MRY0T4", saving="CME_MRY0T4.yaml") # converted locally
912
+ ```
913
+
914
+ JSON is written **byte-for-byte as the API served it** — nothing is
915
+ re-serialised, so the file is diffable against upstream. YAML is produced by
916
+ converting that JSON *locally* (the API has no YAML representation) with
917
+ **single-line scalars only**, so Stata's line-oriented Mata YAML reader can
918
+ consume the same output. `replace=True` overwrites an existing file; `format=`
919
+ overrides what the extension implies. The code route also resolves indicators
920
+ that are **unpublished** in RDM, so reference-only codes work too.
921
+
922
+ #### `info()` never dead-ends
923
+
924
+ A code known to *either* upstream source renders a card, and the card states in
925
+ plain words which half is missing:
926
+
927
+ * **in the registry, no RDM record** (about 25% of it, e.g. the `COD_*`
928
+ cause-of-death series) — the SDMX card plus "No RDM reference metadata for
929
+ this indicator";
930
+ * **in RDM only, no SDMX data** (`identity.has_sdmx is False`; the `SP_*`
931
+ Strategic-Plan codes, which are unpublished in RDM) — what RDM knows plus "No
932
+ SDMX data available … reference metadata only", and **no fetch hint**,
933
+ because there is nothing to fetch;
934
+ * **in neither** — `found: False` and the search hint, as before.
935
+
936
+ The middle case is the root fix for a shipped bug: `describe` rendered
937
+ `SP_QLTY_MNHC` and `SP_POLIO_TRANS` as clickable related indicators, and
938
+ clicking one raised an error, because those codes reach neither the SDMX
939
+ codelist nor the RDM sync's fetched set. They now ship in
940
+ `_unicefdata_rdm_reference_only.yaml` flagged `has_sdmx: false`. Search keeps
941
+ the registry as its universe, so reference-only codes are **excluded from
942
+ search results by default**.
943
+
944
+ ---
945
+
946
+ ### Combining Options
947
+
948
+ ```python
949
+ df = unicefData(
950
+ indicator=["CME_MRY0T4", "CME_MRM0"],
951
+ countries=["ALB", "BRA", "IND", "NGA", "USA"],
952
+ format="wide_indicators",
953
+ latest=True,
954
+ add_metadata=["region", "income_group"],
955
+ dropna=True
956
+ )
957
+ print(df[["iso3", "country", "CME_MRY0T4", "CME_MRM0", "region", "income_group"]].to_string(index=False))
958
+ ```
959
+
960
+ ```
961
+ iso3 country CME_MRY0T4 CME_MRM0 region income_group
962
+ ALB Albania 9.227080 6.735194 Europe and Central Asia Upper middle income
963
+ BRA Brazil 14.216972 7.124973 Latin America and Caribbean Upper middle income
964
+ IND India 26.579900 16.659252 South Asia Lower middle income
965
+ NGA Nigeria 115.649434 39.045723 Sub-Saharan Africa Lower middle income
966
+ USA United States 6.472463 3.652385 North America High income
967
+ ```
968
+
969
+ ---
970
+
971
+ ## Visualizations
972
+
973
+ The following examples use [matplotlib](https://matplotlib.org/), which is not a required dependency but is commonly available. Install with `pip install matplotlib` if needed.
974
+
975
+ ### Time-Series Line Chart
976
+
977
+ ```python
978
+ import matplotlib.pyplot as plt
979
+ from unicefdata import unicefData
980
+
981
+ df = unicefData(
982
+ indicator="CME_MRY0T4",
983
+ countries=["ALB", "BRA", "DEU", "IND", "NGA", "USA"],
984
+ year="2000:2024"
985
+ )
986
+
987
+ country_colors = {
988
+ "ALB": "#4CAF50", "BRA": "#FF9800", "DEU": "#2196F3",
989
+ "IND": "#9C27B0", "NGA": "#F44336", "USA": "#00BCD4"
990
+ }
991
+
992
+ fig, ax = plt.subplots(figsize=(10, 5))
993
+ for iso3, grp in df.groupby("iso3"):
994
+ grp_sorted = grp.sort_values("period")
995
+ ax.plot(grp_sorted["period"], grp_sorted["value"],
996
+ marker="o", markersize=3,
997
+ color=country_colors.get(iso3, "#999"),
998
+ label=grp_sorted["country"].iloc[0])
999
+
1000
+ ax.set_title("Under-5 Mortality Rate (CME_MRY0T4), 2000–2024", fontweight="bold")
1001
+ ax.set_xlabel("Year")
1002
+ ax.set_ylabel("Deaths per 1,000 live births")
1003
+ ax.legend(loc="upper right", fontsize=9)
1004
+ ax.grid(True, alpha=0.3)
1005
+ plt.tight_layout()
1006
+ plt.show()
1007
+ ```
1008
+
1009
+ ![Time-series line chart: under-5 mortality rate 2000–2024](https://raw.githubusercontent.com/unicef-drp/unicefData/main/python/examples/fig01_timeseries.png)
1010
+
1011
+ ### Cross-Country Bar Chart (Latest Values)
1012
+
1013
+ ```python
1014
+ import matplotlib.pyplot as plt
1015
+ from matplotlib.patches import Patch
1016
+ from unicefdata import unicefData
1017
+
1018
+ df = unicefData(
1019
+ indicator="CME_MRY0T4",
1020
+ countries=["ALB", "BRA", "CHN", "DEU", "ETH", "IND", "MEX", "NGA", "USA", "ZAF"],
1021
+ latest=True,
1022
+ add_metadata=["income_group"]
1023
+ )
1024
+ df_sorted = df.sort_values("value", ascending=True)
1025
+
1026
+ income_colors = {
1027
+ "High income": "#2196F3",
1028
+ "Upper middle income": "#4CAF50",
1029
+ "Lower middle income": "#FF9800",
1030
+ "Low income": "#F44336"
1031
+ }
1032
+
1033
+ fig, ax = plt.subplots(figsize=(9, 5))
1034
+ bars = ax.barh(
1035
+ df_sorted["country"],
1036
+ df_sorted["value"],
1037
+ color=[income_colors.get(ig, "#999") for ig in df_sorted["income_group"]]
1038
+ )
1039
+ ax.bar_label(bars, fmt="%.1f", padding=4, fontsize=9)
1040
+ handles = [Patch(color=c, label=l) for l, c in income_colors.items()
1041
+ if l in df_sorted["income_group"].values]
1042
+ ax.legend(handles=handles, title="Income group", fontsize=8)
1043
+ ax.set_title("Under-5 Mortality Rate — Latest Available Year", fontweight="bold")
1044
+ ax.set_xlabel("Deaths per 1,000 live births")
1045
+ ax.grid(axis="x", alpha=0.3)
1046
+ plt.tight_layout()
1047
+ plt.show()
1048
+ ```
1049
+
1050
+ ![Bar chart: under-5 mortality rate by country, coloured by income group](https://raw.githubusercontent.com/unicef-drp/unicefData/main/python/examples/fig02_barchart.png)
1051
+
1052
+ ### Scatter Plot: Two Indicators by Country
1053
+
1054
+ ```python
1055
+ import numpy as np
1056
+ import matplotlib.pyplot as plt
1057
+ from unicefdata import unicefData
1058
+
1059
+ df = unicefData(
1060
+ indicator=["CME_MRY0T4", "CME_MRM0"],
1061
+ format="wide_indicators",
1062
+ latest=True,
1063
+ add_metadata=["income_group"],
1064
+ dropna=True
1065
+ )
1066
+
1067
+ income_colors = {
1068
+ "High income": "#2196F3",
1069
+ "Upper middle income": "#4CAF50",
1070
+ "Lower middle income": "#FF9800",
1071
+ "Low income": "#F44336"
1072
+ }
1073
+
1074
+ fig, ax = plt.subplots(figsize=(8, 6))
1075
+ for ig, grp in df.groupby("income_group"):
1076
+ ax.scatter(grp["CME_MRM0"], grp["CME_MRY0T4"],
1077
+ color=income_colors.get(ig, "#999"), label=ig, alpha=0.7, s=50)
1078
+
1079
+ x, y = df["CME_MRM0"].values, df["CME_MRY0T4"].values
1080
+ m, b = np.polyfit(x, y, 1)
1081
+ xline = np.linspace(x.min(), x.max(), 100)
1082
+ ax.plot(xline, m * xline + b, color="#333", linewidth=1.2, linestyle="--", alpha=0.6, label="Trend")
1083
+
1084
+ ax.set_xlabel("Neonatal Mortality Rate (CME_MRM0)")
1085
+ ax.set_ylabel("Under-5 Mortality Rate (CME_MRY0T4)")
1086
+ ax.set_title("Neonatal vs Under-5 Mortality — All Countries, Latest Values", fontweight="bold")
1087
+ ax.legend(title="Income group", fontsize=8)
1088
+ ax.grid(True, alpha=0.3)
1089
+ plt.tight_layout()
1090
+ plt.show()
1091
+ ```
1092
+
1093
+ ![Scatter plot: neonatal vs under-5 mortality, all countries, coloured by income group](https://raw.githubusercontent.com/unicef-drp/unicefData/main/python/examples/fig03_scatter.png)
1094
+
1095
+ ---
1096
+
1097
+ ## Advanced: UNICEFSDMXClient
1098
+
1099
+ For lower-level access, use `UNICEFSDMXClient` directly.
1100
+
1101
+ ```python
1102
+ from unicefdata import UNICEFSDMXClient
1103
+
1104
+ client = UNICEFSDMXClient()
1105
+
1106
+ # Fetch a single indicator
1107
+ df = client.fetch_indicator(
1108
+ "CME_MRY0T4",
1109
+ countries=["ALB", "USA"],
1110
+ start_year=2020,
1111
+ end_year=2023
1112
+ )
1113
+ print(df[["iso3", "country", "period", "indicator", "value"]].to_string(index=False))
1114
+ ```
1115
+
1116
+ ```
1117
+ iso3 country period indicator value
1118
+ ALB Albania 2020.0 CME_MRY0T4 9.435272
1119
+ ALB Albania 2021.0 CME_MRY0T4 9.456832
1120
+ ALB Albania 2022.0 CME_MRY0T4 9.436385
1121
+ ALB Albania 2023.0 CME_MRY0T4 9.357239
1122
+ USA United States 2020.0 CME_MRY0T4 6.469871
1123
+ USA United States 2021.0 CME_MRY0T4 6.464968
1124
+ USA United States 2022.0 CME_MRY0T4 6.473319
1125
+ USA United States 2023.0 CME_MRY0T4 6.482592
1126
+ ```
1127
+
1128
+ ```python
1129
+ # Fetch multiple indicators combined into one DataFrame
1130
+ df = client.fetch_multiple_indicators(
1131
+ ["CME_MRY0T4", "CME_MRM0"],
1132
+ countries=["ALB", "USA"],
1133
+ combine=True
1134
+ )
1135
+ print(f"Shape: {df.shape}")
1136
+ print(df.groupby(["iso3", "indicator"])["value"].agg(["count", "mean"]).round(2))
1137
+ ```
1138
+
1139
+ ```
1140
+ Shape: (226, 21)
1141
+
1142
+ count mean
1143
+ iso3 indicator
1144
+ ALB CME_MRM0 72.0 12.89
1145
+ CME_MRY0T4 72.0 18.79
1146
+ USA CME_MRM0 41.0 5.48
1147
+ CME_MRY0T4 41.0 9.15
1148
+ ```
1149
+
1150
+ ```python
1151
+ # Configurable timeout
1152
+ client = UNICEFSDMXClient(timeout=120)
1153
+ ```
1154
+
1155
+ ---
1156
+
1157
+ ## API Reference
1158
+
1159
+ ### unicefData()
1160
+
1161
+ Main function for fetching UNICEF indicator data.
1162
+
1163
+ | Parameter | Type | Default | Description |
1164
+ |-----------|------|---------|-------------|
1165
+ | `indicator` | str/list | required | Indicator code(s) |
1166
+ | `dataflow` | str | auto-detect | SDMX dataflow ID |
1167
+ | `countries` | list | None (all) | ISO3 country codes |
1168
+ | `year` | int/str/list | None (all) | Year(s) |
1169
+ | `circa` | bool | False | Find closest year |
1170
+ | `sex` | str | `"_T"` | Sex filter |
1171
+ | `max_retries` | int | 3 | Retry attempts |
1172
+
1173
+ #### Post-Production Parameters
1174
+
1175
+ | Parameter | Type | Default | Description |
1176
+ |-----------|------|---------|-------------|
1177
+ | `format` | str | `"long"` | `"long"`, `"wide"`, `"wide_indicators"` |
1178
+ | `latest` | bool | False | Keep only latest per country |
1179
+ | `mrv` | int | None | Keep N most recent values |
1180
+ | `add_metadata` | list or str | None | Metadata to add (`"rdm"` = RDM enrichment group) |
1181
+ | `rdm_metadata` | bool | True | Attach RDM reference record as `df.attrs["rdm_metadata"]`; `False` disables |
1182
+ | `dropna` | bool | False | Remove missing values |
1183
+ | `simplify` | bool | False | Keep only essential columns |
1184
+
1185
+ ### Other Functions
1186
+
1187
+ | Function | Description |
1188
+ |----------|-------------|
1189
+ | `search_indicators(query, category, limit, type, sdg, flags, sector, custodian, tag, dataflow, fields, quiet)` | Search the card store (offline); prints and returns a DataFrame |
1190
+ | `get_indicator_card(code)` | Full indicator card (offline) — identity, reference, long-form, taxonomy, classification, related, dims, links, provenance |
1191
+ | `info(code, full, quiet)` | Print the indicator card as text; returns the card |
1192
+ | `describe_indicator(code, save, generated_at)` | Flat view over the card; `save=` writes the card as YAML |
1193
+ | `card_to_yaml(card, path, generated_at)` | Write a card as a standalone single-indicator YAML |
1194
+ | `rdm_record(code, saving, format, replace)` | Download the **raw** RDM record (export path A, live); JSON verbatim, YAML converted locally |
1195
+ | `list_categories()` | List all categories |
1196
+ | `list_dataflows()` | List available dataflows |
1197
+ | `dataflow_schema(dataflow)` | Get dataflow schema |
1198
+ | `clear_cache()` | Clear all 5 cache layers |
1199
+
1200
+ ---
1201
+
1202
+ ## Time Period Handling
1203
+
1204
+ Monthly periods are converted to decimal years:
1205
+
1206
+ | Original | Decimal | Calculation |
1207
+ |----------|---------|-------------|
1208
+ | `2020` | `2020.0` | Integer year |
1209
+ | `2020-01` | `2020.0833` | 2020 + 1/12 |
1210
+ | `2020-06` | `2020.5000` | 2020 + 6/12 |
1211
+
1212
+ ---
1213
+
1214
+ ## Common Indicators
1215
+
1216
+ ### Child Mortality (SDG 3.2)
1217
+ - `CME_MRM0` - Neonatal mortality rate
1218
+ - `CME_MRY0T4` - Under-5 mortality rate
1219
+
1220
+ ### Nutrition (SDG 2.2)
1221
+ - `NT_ANT_HAZ_NE2_MOD` - Stunting prevalence
1222
+ - `NT_ANT_WHZ_NE2` - Wasting prevalence
1223
+
1224
+ ### Immunization (SDG 3.b)
1225
+ - `IM_DTP3` - DTP3 coverage
1226
+ - `IM_MCV1` - Measles coverage
1227
+
1228
+ ### WASH (SDG 6)
1229
+ - `WS_PPL_W-SM` - Safely managed water
1230
+ - `WS_PPL_S-SM` - Safely managed sanitation
1231
+
1232
+ ### Child Protection
1233
+ - `PT_CHLD_Y0T4_REG` - Birth registration
1234
+ - `PT_F_20-24_MRD_U18_TND` - Child marriage
1235
+
1236
+ ---
1237
+
1238
+ ## Error Handling
1239
+
1240
+ ```python
1241
+ from unicefdata import SDMXNotFoundError, SDMXBadRequestError, SDMXTimeoutError
1242
+
1243
+ try:
1244
+ df = unicefData(indicator="INVALID_CODE")
1245
+ except SDMXNotFoundError as e:
1246
+ print(f"Indicator not found: {e}")
1247
+ except SDMXBadRequestError as e:
1248
+ print(f"Invalid request: {e}")
1249
+ except SDMXTimeoutError as e:
1250
+ print(f"Request timed out: {e}")
1251
+ ```
1252
+
1253
+ ---
1254
+
1255
+ ## Troubleshooting
1256
+
1257
+ ### Connection Errors
1258
+
1259
+ A request that fails after the retries (no connection, a 429 rate limit, a
1260
+ 5xx) raises `SDMXServerError` (`SDMXUnavailableError` for 503); a timeout
1261
+ raises `SDMXTimeoutError`. All are `SDMXError`. Before 3.0.0 a failure gave
1262
+ an empty frame, which looked like "no data".
1263
+
1264
+ ```python
1265
+ from unicefdata.sdmx_client import SDMXError
1266
+
1267
+ try:
1268
+ df = unicefData(indicator="CME_MRY0T4", max_retries=5) # more retries
1269
+ except SDMXError as e: # also SDMXNotFoundError: an indicator no dataflow serves
1270
+ print(e)
1271
+ ```
1272
+
1273
+ ### Stale Cache
1274
+
1275
+ ```python
1276
+ from unicefdata import clear_cache
1277
+ clear_cache() # Clears all 5 cache layers
1278
+ ```
1279
+
1280
+ ---
1281
+
1282
+ ## Examples
1283
+
1284
+ See `examples/` folder:
1285
+
1286
+ - `00_quick_start.py` - Basic usage
1287
+ - `01_indicator_discovery.py` - Finding indicators
1288
+ - `02_sdg_indicators.py` - SDG queries
1289
+ - `03_data_formats.py` - Output formats
1290
+ - `04_metadata_options.py` - Metadata enrichment
1291
+ - `05_advanced_features.py` - Advanced options
1292
+
1293
+ ---
1294
+
1295
+ ## Version History
1296
+
1297
+ See [CHANGELOG.md](https://github.com/unicef-drp/unicefData/blob/main/python/CHANGELOG.md) for complete changelog.
1298
+
1299
+ ---
1300
+
1301
+ ## Dependencies
1302
+
1303
+ - pandas
1304
+ - requests
1305
+ - pyyaml
1306
+
1307
+ Optional: `pip install "unicefdata[excel]"` for Excel export support.
1308
+
1309
+ ---
1310
+
1311
+ ## Acknowledgments
1312
+
1313
+ This package was developed at the UNICEF Data and Analytics Section. The author gratefully acknowledges the collaboration of **Lucas Rodrigues**, **Yang Liu**, and **Karen Avanesian**, whose technical contributions and feedback were instrumental in the development of this Python package.
1314
+
1315
+ Special thanks to **Yves Jaques**, **Alberto Sibileau**, and **Daniele Olivotti** for designing and maintaining the UNICEF SDMX data warehouse infrastructure that makes this package possible.
1316
+
1317
+ The author also acknowledges the **UNICEF database managers** and technical teams who ensure data quality, as well as the country office staff and National Statistical Offices whose data collection efforts make this work possible.
1318
+
1319
+ Development of this package was supported by UNICEF institutional funding for data infrastructure and statistical capacity building. The author also acknowledges UNICEF colleagues who provided testing and feedback during development, as well as the broader open-source Python community.
1320
+
1321
+ Development was assisted by AI coding tools (GitHub Copilot, Claude). All code has been reviewed, tested, and validated by the package maintainers.
1322
+
1323
+ ## Disclaimer
1324
+
1325
+ **This package is provided for research and analytical purposes.**
1326
+
1327
+ The `unicefData` package provides programmatic access to UNICEF's public data warehouse. While the author is affiliated with UNICEF, **this package is not an official UNICEF product and the statements in this documentation are the views of the author and do not necessarily reflect the policies or views of UNICEF**.
1328
+
1329
+ Data accessed through this package comes from the [UNICEF Data Warehouse](https://sdmx.data.unicef.org/). Users should verify critical data points against official UNICEF publications at [data.unicef.org](https://data.unicef.org/).
1330
+
1331
+ This software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or UNICEF be liable for any claim, damages or other liability arising from the use of this software.
1332
+
1333
+ The designations employed and the presentation of material in this package do not imply the expression of any opinion whatsoever on the part of UNICEF concerning the legal status of any country, territory, city or area or of its authorities, or concerning the delimitation of its frontiers or boundaries.
1334
+
1335
+ ## Data Citation and Provenance
1336
+
1337
+ **Important Note on Data Vintages**
1338
+
1339
+ Official statistics are subject to revisions as new information becomes available and estimation methodologies improve. UNICEF indicators are regularly updated based on new surveys, censuses, and improved modeling techniques. Historical values may be revised retroactively to reflect better information or methodological improvements.
1340
+
1341
+ **For reproducible research and proper data attribution, users should:**
1342
+
1343
+ 1. **Document the indicator code** - Specify the exact SDMX indicator code(s) used (e.g., `CME_MRY0T4`)
1344
+ 2. **Record the download date** - Note when data was accessed (e.g., "Data downloaded: 2026-03-20")
1345
+ 3. **Cite the data source** - Reference both the package and the UNICEF Data Warehouse
1346
+ 4. **Archive your dataset** - Save a copy of the exact data used in your analysis
1347
+
1348
+ **Example citation for data used in research:**
1349
+
1350
+ > Under-5 mortality data (indicator: CME_MRY0T4) accessed from UNICEF Data Warehouse via unicefData Python package (v3.0.0) on 2026-12-04. Data available at: https://sdmx.data.unicef.org/
1351
+
1352
+ This practice ensures that others can verify your results and understand any differences that may arise from data updates. For official UNICEF statistics in publications, always cross-reference with the current version at [data.unicef.org](https://data.unicef.org/).
1353
+
1354
+ ## Citation
1355
+
1356
+ If you use this package, please cite:
1357
+
1358
+ > Azevedo, Joao Pedro (2026). "unicefdata: Unified access to UNICEF indicators across R, Python, and Stata." Mimeo, UNICEF Chief Statistician Office.
1359
+
1360
+ ---
1361
+
1362
+ ## Development
1363
+
1364
+ Development assisted by AI coding tools (GitHub Copilot, Claude). All code reviewed and validated by maintainers.
1365
+
1366
+ ---
1367
+
1368
+ ## Author
1369
+
1370
+ **Joao Pedro Azevedo** ([@jpazvd](https://github.com/jpazvd))
1371
+ Chief Statistician, UNICEF Data and Analytics Section
1372
+ Email: jpazevedo@unicef.org
1373
+ Website: [jpazvd.github.io](https://jpazvd.github.io/)
1374
+
1375
+ ---
1376
+
1377
+ ## License
1378
+
1379
+ MIT License - See [LICENSE](https://github.com/unicef-drp/unicefData/blob/main/python/LICENSE)
1380
+
1381
+ ## Contributing
1382
+
1383
+ See [CONTRIBUTING.md](https://github.com/unicef-drp/unicefData/blob/main/CONTRIBUTING.md) for detailed guidelines.