Building a Covid-19 Dashboard using Streamlit and Python
Astha Mular — Published On February 23, 2021
This article was published as a part of the Data Science Blogathon.
I have built a covid-19 dashboard using Streamlit python. Streamlit is an open source app framework for machine learning and data science used to build interactive and beautiful apps easily. This dashboard contains data visualization of covid of all the states of India. Data is visualized with the help of a bar chart, pie chart, and line graph.
The link for the dashboard is here.
Through this article we will cover the following topics :
- Installing Streamlit
- Building dashboard
- Running streamlit app
- Making requirements file
- Sharing dashboard
Installing Streamlit :
- Make sure you have python 3.6 – 3.8 already installed.
- pip install streamlit.
- import streamlit to check if it’s installed.
Building dashboard :
- start with importing libraries which we will need.
- Using imported library streamlit we can give title and introduction to our dashboard .In addition to this you can add image if u wish and background color .
- st.title( ) for giving heading to the dashboard .
- st.sidebar( ) for displaying data on the sidebar
- st.image( ) for inserting image on the dashboard
- st.markdown( ) to display text as markdown .
Loading the data
st.cache decorator indicates that Streamlit will perform internal magic so that the data will be downloaded only once and cached for the future. Streamlit keeps track of the function name, the code in the function body, and the input arguments we pass in the function call.
The main limitation of Streamlit’s data caching is that it cannot keep track of changes to the data happening outside of the function body.
Selector code :
Use a selection of options
In the visualization part, we need to plot graphs based on the status of covid patients and the Number of cases of coronavirus in a particular state or selected state.
Get the dataset: If you wish to show the dataset you have used on the dashboard, this can also be done.
Running Streamlit App
Share your App
Put your app in a public GitHub repo along with the requirements.txt file.
To create requirements.txt use the following command on the anaconda command prompt.
pip install pipreqs pipreqs .location
After doing the above commands you will get requirements.txt successfully saved in your required location.
Sign in to share.streamlit.io
Click on ‘Deploy an app’ and then paste your GitHub URL.
The media shown in this article are not owned by Analytics Vidhya and is used at the Author’s discretion.
Leave a Reply Your email address will not be published. Required fields are marked *