World Bank API Python DashBoard
The project uses the data available from World Bank API Python for visualizations.
Limitation: No option to change World Bank API Database from DashBoard/GUI
Dash App
Multi App
In Multi App, the User can choose two indicators on x-axis and y-axis respectively. The user can look for multi-variable trends for economies.
- Trendline
- OLS
- Lowess
- Plots
- Line
- Scatter
- Add/Remove: Markers and Years
- Switch Axis Variables Button
- Indicator Descriptions (Info Button)
- Linear/Log Scales
Simple App
It is one variable App where user can only change y-axis variable while x-axis is by set to Year
by default. It accepts only one indicator while it is possible to add as many economies as possible.
- OLS Trendline
- Linear/Log Scale
Possibility to Switch
It is possible to switch from Simple to Multi App or vice versa.
Limitation
If App was switched or refreshed, the selections will reset to default. The default settings can be changed from within scripts.
Download Graphs as .png
The interactive plotly has the option to download the graphs too.
Incredible Search
Default Database
World Bank API is set to World Development Indicators (WDI) Database, id=2, by the module developers. wb.source.info()
provides the list of available Databases from World Bank API.
import wbgapi as wb
wb.source.info() #provide the list of DBs
wb.db # id number of current Database i.e: (WDI=2)
Globally
In case, of a different database request, the wb.db
value has to be changed at the top of appSupport.py
wb.db = 1
Download & Install Conda
Install: Miniconda for GNU/Linux or Windows
GNU/Linux: Too Easy to Install
Windows 10
Take note of Miniconda3 installation path.
During Miniconda3 installation tick:
- Add Miniconda3 to my PATH environment variable
- Register Miniconda3 as my default Python 3.9
Windows 7
The Python interpreters <= 3.8
are compatible.
GNU/Linux
Install Git
sudo apt-get update
sudo apt-get install git
Download Github Repository
git clone https://github.com/mirbehroznoor/World-Bank-API-Python-DashBoard
Conda Environment
Python Dependencies
In environment.yml
, the conda environment is named wbconda
cat environment.yml
name: wbconda channels: - conda-forge dependencies: - python==3.10 - dash==2.3.1 - wbgapi==1.0.7 - plotly==5.7.0 - pandas==1.4.2 - black - pip - pip: - statsmodels==0.13.2 - dash_bootstrap_components==1.1.0 - dash-iconify==0.1.2
Create Conda Environment
bash build_env.sh
Run Python App
Simply run the app.py
script. The App will open in the default browser after few seconds.
Manually
cd ~/path/to/World-Bank-API-Python-DashBoard
conda activate wbconda
python app.py
Automate
Write Bash Alias function
Find or create .bash_aliases
in folder $HOME
Directory. Insert the function snippet:
wbapp() {
cd ~/path/to/World-Bank-API-Python-DashBoard
conda activate wbconda
python app.py
}
For shell to re-read the .bash_aliases
file, run the following command:
source ~/.bashrc
Afterwards in Terminal, simply run:
wbapp
Instructions.txt
Windows 10First Option:
Git for Windows
Install git for windows (with default options) Install: Git for Windows
Download World Bank API files from Github Repository
Add Conda Path
Open Git Bash Add conda.sh Path in Git Bash
#Type in Git Bash
. C:/Users/your-username/miniconda3/etc/profile.d/conda.sh
Setup Conda Env
Manually open extracted path in Git Bash:
cd ~ /path/to/World-Bank-API-Python-Dashboard
bash build_env.sh #Creates Conda Environment
Run the App
#Activates conda Environment
conda activate wbconda
#Runs Application
python app.py
Open in Browser
If the App does not open automatically in your favorite browser. Visit App URL:
localhost:8050
<OR>
http://127.0.0.1:8050
Close or Terminate Server
To exit Git Bash server press Ctrl + C
in terminal
<OR>
To close Git Bash Enter exit
After Setup
To Re-run after initial installation (for later use or once Git Bash is closed): Open Git Bash Manually navigate to extracted files path
. C:/Users/your-username/miniconda3/etc/profile.d/conda.sh
conda activate wbconda
Python app.py
Second Option:
The following instructions may not be accurate
Install PyCharm
Create a Project
Git Clone
Option from PyCharm Stackoverflow: Import github Repository to PyCharm
Use the Setup Conda Env within PyCharm
- For Conda Env:
environment.yml
- For Pyevn Env:
requirements.txt
Run the App.py
Share it with others!
- Whoever can use it
Acknowledgments
- Towardsdatascience: Extract key from python dictionary
- Logrocket Blog: Data Visualization Interfaces Python Dash
- World Bank Blogs: Introducing wbgapi New Python Package Accessing World Bank Data
- Github: wbgapi
- Dash-Plotly: Interactive Graphing
- Dash-Plotly: Legend
- Dash-Plotly: Multi-Page Apps & URLs Support
- Stackoverflow: Prevent a callback from firing in dash
- Stackoverflow: Import github Repository to PyCharm
- Dash App Stylesheets: Dash Analytics Report