Skip to main content

Easy access to Morocco's official demographic data (HCP – RGPH 2024) for data scientists and analysts.

Project description

Ayoub_Allali_HCP_Data

PyPI version Python 3.8+ License: MIT

A Python library that gives data scientists and analysts instant access to Morocco's official demographic data published by the Haut-Commissariat au Plan (HCP) – General Population and Housing Census RGPH 2024.

Data source: hcp.ma – Recensement Général de la Population et de l'Habitat 2024.


Installation

pip install Ayoub-Allali-HCP-Data

Quick Start

import ayoub_allali_hcp_data as hcp

# Discover all datasets
hcp.info()

# --- Scalar values ---
print(hcp.get_population_legale())     # 36828330
print(hcp.get_nombre_menages())        # 9275038
print(hcp.get_taux_urbanisation())     # 0.628

# --- DataFrames ---
df = hcp.get_population_historique()
print(df)

Available Datasets

Function Description
get_population_legale() Official legal population – 2024 (int)
get_nombre_menages() Total number of households – 2024 (int)
get_taux_urbanisation() Urbanisation rate – 2024 (float, e.g. 0.628)
get_population_historique() Population & growth rate per census (1960–2024)
get_population_urbaine_rurale() Urban / Rural counts & urbanisation rate (1960–2024)
get_structure_age() Age-group distribution % – Ensemble / Urban / Rural (2024)
get_fecondite() Total Fertility Rate by milieu (2024)
get_acces_reseaux_publics() % HH with access to water, electricity, sanitation (2024)
get_taille_menage() Average household size – Ensemble / Urban / Rural (2004–2024)

You can also use the generic load() function:

df = hcp.load("structure_age")

And list all dataset names:

hcp.list_datasets()
# ['acces_reseaux_publics', 'fecondite', 'nombre_menages', ...]

Detailed Examples

Population history

import ayoub_allali_hcp_data as hcp
import matplotlib.pyplot as plt

df = hcp.get_population_historique()
print(df)
#    Année    Population  Taux d'accroissement
# 0   1960  1.162647e+07                   NaN
# 1   1971  1.537926e+07                  2.58
# 2   1982  2.041956e+07                  2.61
# 3   1994  2.607372e+07                  2.06
# 4   2004  2.989171e+07                  1.38
# 5   2014  3.384824e+07                  1.25
# 6   2024  3.682833e+07                  0.85

plt.plot(df["Année"], df["Population"] / 1e6, marker="o")
plt.title("Population du Maroc (millions)")
plt.xlabel("Année"); plt.ylabel("Population (M)")
plt.show()

Urban vs Rural breakdown

df = hcp.get_population_urbaine_rurale()
print(df)
#    Année    Urbain     Rural   Ensemble  Taux d'urbanisation (%)
# 0   1960   3389613   8236857  11626470                      29.2
# ...
# 6   2024  23110108  13718222  36828330                      62.8

Access to public utilities

df = hcp.get_acces_reseaux_publics()
print(df)
#        Réseaux publics  Urbain  Rural  Ensemble
# 0         Eau courante    97.1   54.6      82.9
# 1          Electricité    98.6   91.8      96.3
# 2       Assainissement    93.4    9.6      65.4

Fertility rate

df = hcp.get_fecondite()
print(df)
#       Milieu  Indice synthétique de fécondité
# 0   Ensemble                              2.0
# 1     Urbain                              1.8
# 2      Rural                              2.4

License

MIT © Ayoub Allali

Data is published by HCP Morocco and is used here for educational and research purposes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ayoub_allali_hcp_data-1.0.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ayoub_allali_hcp_data-1.0.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file ayoub_allali_hcp_data-1.0.0.tar.gz.

File metadata

  • Download URL: ayoub_allali_hcp_data-1.0.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for ayoub_allali_hcp_data-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fe9ec23a35660a6279fff578dc1c42026834e38b1b306d2c62fda4ba9c381fc5
MD5 aa53722aa94da048f0837f03daaf62c3
BLAKE2b-256 263b6fc4636f0b9a2419794f1e8a03346b75af8cd9a0db49840b93f752ea3e7f

See more details on using hashes here.

File details

Details for the file ayoub_allali_hcp_data-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ayoub_allali_hcp_data-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31bd8d42cdabd328cafcad6a0537e14852cc26b69d692625ab0446c7cd850d5e
MD5 510e0540c59f5d8a48900f2ffa1cdcaa
BLAKE2b-256 ada2a7f3231bc10929c0da01ef791e226d52b48c9b78e5127ad8db1211c9db14

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page