Un package Python pour analyser les données économiques du Sénégal via l'API World Bank
Project description
Senegal Economic Data Explorer
Un package Python pour analyser facilement les données économiques du Sénégal et d'autres pays via l'API World Bank.
🚀 Installation
Depuis PyPI (recommandé)
pip install senegal-economic-data-explorer
Depuis les sources
git clone https://github.com/MARAMATA/senegal-economic-data-explorer.git
cd senegal-economic-data-explorer
pip install -e .
📖 Utilisation
Import du package
from data_explorer import get_export, get_import, get_pib
Exemples d'utilisation
1. Récupérer les exportations du Sénégal
# Exportations du Sénégal de 2010 à 2023
df_export = get_export("SN", 2010, 2023)
print(df_export.head())
2. Récupérer les importations
# Importations du Sénégal
df_import = get_import("SN", 2015, 2023)
print(f"Total des importations en 2023: ${df_import[df_import['annee']==2023]['importations_usd'].values[0]:,.0f}")
3. Récupérer le PIB d'un ou plusieurs pays
# PIB du Sénégal uniquement
df_pib_sn = get_pib("SN", 2000, 2023)
# PIB de plusieurs pays
df_pib_multiple = get_pib(["SN", "FR", "US", "CN"], 2020, 2023)
print(df_pib_multiple.pivot(index='annee', columns='code_pays', values='pib_usd'))
Exemple complet d'analyse
import pandas as pd
import matplotlib.pyplot as plt
from data_explorer import get_export, get_import, get_pib
# Récupération des données
exports = get_export("SN", 2010, 2023)
imports = get_import("SN", 2010, 2023)
pib = get_pib("SN", 2010, 2023)
# Fusion des données
df = pd.merge(exports, imports, on=['code_pays', 'nom_pays', 'annee'])
df = pd.merge(df, pib, on=['code_pays', 'nom_pays', 'annee'])
# Calcul de la balance commerciale
df['balance_commerciale'] = df['exportations_usd'] - df['importations_usd']
df['ratio_export_pib'] = (df['exportations_usd'] / df['pib_usd']) * 100
# Visualisation
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(10, 8))
# Balance commerciale
ax1.plot(df['annee'], df['balance_commerciale']/1e9, marker='o')
ax1.axhline(y=0, color='r', linestyle='--', alpha=0.5)
ax1.set_title('Balance commerciale du Sénégal')
ax1.set_ylabel('Milliards USD')
ax1.grid(True, alpha=0.3)
# Ratio exports/PIB
ax2.plot(df['annee'], df['ratio_export_pib'], marker='s', color='green')
ax2.set_title('Ratio Exportations/PIB')
ax2.set_xlabel('Année')
ax2.set_ylabel('Pourcentage (%)')
ax2.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()
📊 Indicateurs disponibles
Le package utilise les indicateurs suivants de la World Bank :
- PIB :
NY.GDP.MKTP.CD- Produit Intérieur Brut en USD courants - Population :
SP.POP.TOTL- Population totale - Exportations :
NE.EXP.GNFS.CD- Exportations de marchandises en USD - Importations :
NE.IMP.GNFS.CD- Importations de marchandises en USD - Dépenses publiques :
GC.XPN.TOTL.GD.ZS- Dépenses publiques en % du PIB
🔧 Développement
Installation en mode développement
git clone https://github.com/MARAMATA/senegal-economic-data-explorer.git
cd senegal-economic-data-explorer
pip install -e ".[dev]"
Lancer les tests
pytest
# ou avec coverage
pytest --cov=data_explorer
Formater le code
black data_explorer tests
flake8 data_explorer tests
📦 Publier sur PyPI
-
Créer un compte sur PyPI
-
Installer les outils nécessaires
pip install twine build
- Construire le package
python -m build
- Vérifier le package
twine check dist/*
- Publier sur TestPyPI (optionnel, pour tester)
twine upload --repository testpypi dist/*
- Publier sur PyPI
twine upload dist/*
🤝 Contribution
Les contributions sont les bienvenues ! N'hésitez pas à :
- Fork le projet
- Créer une branche pour votre fonctionnalité (
git checkout -b feature/AmazingFeature) - Commit vos changements (
git commit -m 'Add some AmazingFeature') - Push vers la branche (
git push origin feature/AmazingFeature) - Ouvrir une Pull Request
📝 Licence
Ce projet est sous licence MIT. Voir le fichier LICENSE pour plus de détails.
🙏 Remerciements
- World Bank API pour l'accès aux données
- La communauté Python pour les excellentes bibliothèques pandas et requests
📞 Contact
Maramata DIOP - GitHub - maramatad@gmail.com - Tel: +221 76 024 95 83
Lien du projet : https://github.com/MARAMATA/senegal-economic-data-explorer
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file senegal_economic_data_explorer-0.1.0.tar.gz.
File metadata
- Download URL: senegal_economic_data_explorer-0.1.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f18d522f612e3e314ce16560e8b55ad249fc92936d3b47174dca7a72a02dd316
|
|
| MD5 |
dc155404c6291ebf805737742b46a272
|
|
| BLAKE2b-256 |
cc8f1907dc7c0279ff1c8e06965e9283af5652a32636aebf4ae544e7ba1907df
|
File details
Details for the file senegal_economic_data_explorer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: senegal_economic_data_explorer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3c5befcfd5543c8b3c3742c002110628f3b66e4bbd7691754ad11a9b86fcd7c
|
|
| MD5 |
fe694af939e1efab4ec4ec418285fe81
|
|
| BLAKE2b-256 |
12b2f3226731bf71ec78d3763699249f6951ec180be47d0b6ff3dd49c74d9b97
|