Building a Covid-19 Dashboard using Streamlit and Python

Astha Mular 23 Feb, 2021 • 3 min read
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 .
Covid-19 dashboard streamlit - import
st. - Covid-19 dashboard streamlit


Loading the data



Data Caching
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

selection of options


Visualization Part

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.
visualization Covid-19 dashboard streamlit


bar chart Covid-19 dashboard streamlit

Bar Chart

pie Covid-19 dashboard streamlit

Pie Chart

Get the dataset: If you wish to show the dataset you have used on the dashboard, this can also be done.
Covid-19 dashboard streamlit def table


Running Streamlit App

Covid-19 dashboard streamlit running 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
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.

Astha Mular 23 Feb 2021

Frequently Asked Questions

Lorem ipsum dolor sit amet, consectetur adipiscing elit,

Responses From Readers