Today data is the new oil. People who have data are always is in a competitive advantage over their peers. With data and interpreting the data, they will be able to do business better, run business operations in a more efficient way, and help humanity in moving forward.
There are a lot of BI tools are already available like Tableau, Power BI, Quick view, and our old friend MS excel. But they are not free and comes with a significant amount of price. You can use them offline to create beautiful dashboards but can only share through online services. Even you can send excel files offline, but the other person needs to have MS Excel or Google sheets to view the report.
What if your data interpretation is very simple and you need similar kinds of charts every day to observe a KPI or metric and send it across the team. Just see the COVID dashboard I have created below which you can export as an HTML file and share with others.
To open the BI dashboard, you don’t need any kind of special software, you just need your regular good old browser and can view the interactive dashboard very easily.
To create the dashboard, I have used Python and some of the popular open-source libraries like Pandas, Plotly, Jupyter, etc. I believe this approach is very useful if your objective is to observe a certain KPI day by day and share it with others who don’t have any technical knowledge and requirements.
Dashboard Creation Process:
It is very simple, first open a blank Jupiter notebook (if you don’t know what the jupyter is and how to install it, you can refer here: https://jupyter.org/install).
First import necessary libraries
# importing important libraries
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt# use below methods to use plotly charts in offline mode
import plotly.offline as py
py.init_notebook_mode(connected=False)import plotly.express as px
Here I will use pandas to plot Plotly charts. from version .25 pandas is allowing another backend in pandas charts. As pandas charts are static, to make charts more interactive, I will be using the Plotly backend to create plotly charts using pandas. So first set pandas backend to plotly.
# changing Pandas plot backend to plotlypd.options.plotting.backend = "plotly"
Now the setup process is complete. Let’s import data using pandas and saved it as a data frame. (Here I have used the latest COVID data from ‘Our World in Data’ for analysis: https://github.com/owid/covid-19-data/tree/master/public/data)
In the data, you will find a lot of matrices like total COVID cases, daily COVID cases, vaccination data, different macroeconomic indicators etc. but for my dashboard creation, I have used daily COVID cases, daily COVID deaths, new COVID test per hundred, new vaccinations per hundred, hospital beds per thousands, country-wise cardiac issues, diabetes issues, etc.
# loading the datadata = pd.read_csv('owid-covid-data.csv')# we have selected the data of India as of 16th April 2021data_india = data[data['location'] == 'India']# setting up index = date columndata_india.set_index('date', inplace=True)
Let’s quickly create charts for vaccination, COVID cases, and deaths. To create the charts, I will use the panda’s plot method and assign it to fig to manipulate chart height, weight as per my needs.
India COVID Test and Vaccination Status
# India COVID test and Vaccination Status
India Daily Number of Cases
# India Daily Number of Cases
India Daily Death rates
# number of deaths per day in India
Country-wise Hospital beds per thousands
table = pd.pivot_table(data,index=['location'],aggfunc
and a simple panda’s data frame mentioning country-wise Cardiac and Diabetes issues
The table describing country-wise cardiac death rates and diabetic prevalence (% of the population affected by diabetes)
You can easily check if you have diabetes or not using this ML diabetes predictor APP: https://share.streamlit.io/soumyabrataroy/diabetes_predictor_ml_app/main/diabetes_predictor_V2.py
Now the main part, after you create the charts, you need to convert the Jupiter notebook to the responsive, interactive BI dashboard without any code showing at the output. To do that, you need to use nbconvert package. It usually comes with normal Anaconda installation, but you could also install it using the simple pip command line. Once you install it, go to your command line prompt -> go to the file location of the ipynb file using command line -> write ->
~file path\jupyter nbconvert ipynb_file --to html --no-input# example in my machine
(base) C:\Users\Sam\Documents\COVID dashboard>jupyter nbconvert Offline_COVID_dashboard.ipynb --to html --no-input
always remember, you shouldn’t use any space in the ipynb file name to generate the file, it will raise an error. You should also not use the above code twice in the presence of an earlier generated HTML file, in that case also, it will generate an error. If you need to generate the file multiple times, you should always delete the earlier generated HTML file and then run the above code.
For the respective Jupyter notebook and the HTML dashboard, you can check my GitHub link: https://github.com/soumyabrataroy/Offline-BI-Dashboard
I hope you like the article. I will come back soon with more interesting articles. Stay tuned for more…
Please 👏. It will encourage me to write more good articles.
If you have any questions, thoughts, suggestions, let me know down in the comment below.
Follow me on Twitter: @sam1ceagain
Originally Published on LinkedIn on 21st April’21: https://www.linkedin.com/post/edit/6789423532293009409/