""" Mobile Money Adoption in Africa - Dataset Generator DAG Structure: country → urban_rural, income_quintile year → mobile_money_penetration urban_rural → account_ownership gender → account_ownership age_group → account_ownership, digital_literacy income_quintile → account_ownership, transaction_frequency account_ownership → active_use, transaction_types active_use → avg_transaction_value Parameter Evidence Table: | Parameter | Value | Source | |-----------|-------|--------| | SSA mobile money accounts | 1.1 billion | GSMA SOTIR 2025 | | Global registered accounts | 2 billion | GSMA SOTIR 2025 | | Active users globally | 500M+ | GSMA SOTIR 2025 | | SSA GDP contribution | $190 billion (2023) | GSMA SOTIR 2025 | | Kenya M-Pesa adoption | 84% | World Bank Findex 2025 | | Uganda mobile money | 56% | World Bank Findex 2025 | | Tanzania mobile money | 48% | World Bank Findex 2025 | | Ghana mobile money | 41% | World Bank Findex 2025 | | Nigeria mobile money | 12% | World Bank Findex 2025 | | Urban adoption advantage | 1.5-2x rural | GSMA SOTIR 2025 | | Gender gap | 8-15% lower for women | World Bank Findex 2025 | | Active account rate | 35-45% of registered | GSMA SOTIR 2025 | | Avg transaction value | $50-200 | GSMA SOTIR 2025 | """ import numpy as np import pandas as pd from pathlib import Path COUNTRIES = [ "Kenya", "Uganda", "Nigeria", "Ghana", "Tanzania", "Ethiopia", "Malawi", "Zambia", "Senegal", "Rwanda", "Niger", "Mali", "DRC", "Mozambique", "South Africa" ] YEARS = list(range(2018, 2026)) COUNTRY_BASE_RATES = { "Kenya": 0.84, "Uganda": 0.56, "Tanzania": 0.48, "Ghana": 0.41, "Nigeria": 0.12, "Ethiopia": 0.08, "Malawi": 0.25, "Zambia": 0.32, "Senegal": 0.45, "Rwanda": 0.38, "Niger": 0.18, "Mali": 0.22, "DRC": 0.15, "Mozambique": 0.20, "South Africa": 0.28 } PROVIDERS = { "Kenya": ["M-Pesa", "Airtel Money"], "Uganda": ["MTN Mobile Money", "Airtel Money"], "Tanzania": ["M-Pesa", "Tigo Pesa", "Airtel Money"], "Ghana": ["MTN Mobile Money", "Vodafone Cash", "AirtelTigo Money"], "Nigeria": ["Paga", "OPay", " PalmPay"], "Ethiopia": ["telebirr", "M-Birr"], "Malawi": ["Airtel Money", "TNM Mpamba"], "Zambia": ["MTN Mobile Money", "Airtel Money", "Zamtel Kwacha"], "Senegal": ["Orange Money", "Wave", "Wari"], "Rwanda": ["MTN Mobile Money", "Airtel Money"], "Niger": ["Airtel Money", "Moov Money"], "Mali": ["Orange Money", "Moov Money"], "DRC": ["M-Pesa", "Orange Money", "Airtel Money"], "Mozambique": ["M-Pesa", "e-Mola"], "South Africa": ["Vodapay", "MTN Mobile Money", "FNB eWallet"] } TRANSACTION_TYPES = [ "airtime_purchase", "bill_payment", "person_to_person", "merchant_payment", "cash_withdrawal", "cash_deposit", "savings", "loan_repayment", "international_remittance" ] def generate_scenario(n_samples: int, seed: int, scenario: str) -> pd.DataFrame: rng = np.random.default_rng(seed) country = rng.choice(COUNTRIES, n_samples) year = rng.choice(YEARS, n_samples) urban_rural = np.where( rng.random(n_samples) < 0.42, "urban", "rural" ) gender = rng.choice(["male", "female"], n_samples, p=[0.48, 0.52]) age = rng.integers(15, 75, n_samples) age_group = pd.cut(age, bins=[14, 25, 35, 45, 55, 75], labels=["15-24", "25-34", "35-44", "45-54", "55+"]) income_quintile = rng.choice(["lowest", "second", "middle", "fourth", "highest"], n_samples, p=[0.25, 0.22, 0.20, 0.18, 0.15]) base_rates = np.array([COUNTRY_BASE_RATES[c] for c in country]) year_adj = (year - 2018) * 0.025 urban_adj = np.where(urban_rural == "urban", 0.15, 0.0) gender_adj = np.where(gender == "female", -0.08, 0.0) age_adj = np.where( (age >= 25) & (age <= 44), 0.10, np.where(age < 25, 0.05, -0.05) ) quintile_adj = np.select( [income_quintile == "lowest", income_quintile == "second", income_quintile == "middle", income_quintile == "fourth", income_quintile == "highest"], [-0.15, -0.08, 0.0, 0.08, 0.15] ) ownership_prob = np.clip(base_rates + year_adj + urban_adj + gender_adj + age_adj + quintile_adj, 0.05, 0.95) account_ownership = (rng.random(n_samples) < ownership_prob).astype(int) active_use = np.zeros(n_samples, dtype=int) active_mask = account_ownership == 1 active_prob = np.where(urban_rural[active_mask] == "urban", 0.50, 0.38) active_use[active_mask] = (rng.random(active_mask.sum()) < active_prob).astype(int) n_transactions_monthly = np.zeros(n_samples) trans_mask = active_use == 1 base_trans = np.where(urban_rural[trans_mask] == "urban", 12, 8) n_transactions_monthly[trans_mask] = rng.poisson(base_trans) avg_transaction_value = np.zeros(n_samples) avg_transaction_value[trans_mask] = rng.lognormal( mean=np.log(75) + np.where(urban_rural[trans_mask] == "urban", 0.3, 0), sigma=0.6, size=trans_mask.sum() ) providers = np.empty(n_samples, dtype=object) prov_mask = account_ownership == 1 for i, c in enumerate(country): if prov_mask[i]: providers[i] = rng.choice(PROVIDERS[c]) else: providers[i] = "none" transaction_types_list = [] for i in range(n_samples): if active_use[i] == 1: n_types = rng.integers(2, 6) types = rng.choice(TRANSACTION_TYPES, n_types, replace=False) transaction_types_list.append(",".join(types)) else: transaction_types_list.append("none") digital_literacy = rng.integers(1, 11, n_samples) digital_literacy = np.clip( digital_literacy + np.where(urban_rural == "urban", 1, 0) + np.where(age < 35, 1, 0), 1, 10 ) years_active = np.zeros(n_samples, dtype=int) years_active[account_ownership == 1] = rng.integers( 1, np.maximum(2, year[account_ownership == 1] - 2007), size=active_mask.sum() ) df = pd.DataFrame({ "country": country, "year": year, "urban_rural": urban_rural, "gender": gender, "age": age, "age_group": age_group, "income_quintile": income_quintile, "account_ownership": account_ownership, "active_use": active_use, "provider": providers, "n_transactions_monthly": n_transactions_monthly.astype(int), "avg_transaction_value_usd": np.round(avg_transaction_value, 2), "transaction_types": transaction_types_list, "digital_literacy_score": digital_literacy, "years_active": years_active, "scenario": scenario }) return df def main(): output_dir = Path(__file__).parent scenarios = [ ("low_burden", 4000, 42), ("moderate_burden", 5000, 43), ("high_burden", 6000, 44) ] all_dfs = [] for scenario_name, n, seed in scenarios: df = generate_scenario(n, seed, scenario_name) all_dfs.append(df) output_path = output_dir / f"mobile_money_{scenario_name}.csv" df.to_csv(output_path, index=False) print(f"Generated {output_path}: {len(df)} records") combined = pd.concat(all_dfs, ignore_index=True) combined_path = output_dir / "mobile_money_combined.csv" combined.to_csv(combined_path, index=False) print(f"Generated {combined_path}: {len(combined)} records") if __name__ == "__main__": main()