Sign up for your FREE personalized newsletter featuring insights, trends, and news for America's Active Baby Boomers

Newsletter
New

Build And Deploy An Interactive Sales Dashboard With Streamlit

Card image cap

???? Why Streamlit?

Streamlit is a powerful open-source Python library that turns data scripts into shareable web apps in minutes. It is perfect for data science and machine learning projects.

???? Features of This Project

  • Display data in table format
  • Create a line chart for monthly sales
  • Deploy the dashboard to the web with zero configuration

???? Prerequisites

  • Basic knowledge of Python
  • streamlit, pandas, and matplotlib installed (pip install streamlit pandas matplotlib)
  • A GitHub account
  • A Streamlit Cloud account

????‍???? Full Code (app.py)

import streamlit as st  
import pandas as pd  
import matplotlib.pyplot as plt  
  
# Title  
st.title("Sales Dashboard")  
  
# Sample Data  
data = {  
    "Month": ["Jan", "Feb", "Mar", "Apr", "May"],  
    "Sales": [1500, 1800, 2400, 3000, 2800]  
}  
df = pd.DataFrame(data)  
  
# Show table  
st.subheader("Sales Data")  
st.dataframe(df)  
  
# Line chart  
st.subheader("Sales Line Chart")  
plt.plot(df["Month"], df["Sales"], marker='o')  
plt.xlabel("Month")  
plt.ylabel("Sales")  
plt.grid(True)  
st.pyplot(plt)  

Explanation:

  • st.title, st.subheader, and st.dataframe are used to structure the page layout.
  • matplotlib.pyplot is used to generate the line chart.
  • st.pyplot directly displays the Matplotlib figure inside the Streamlit app.

???? How to Deploy to the Cloud

  1. Push your app.py file to a GitHub repository.
  2. Create a free account on Streamlit Cloud.
  3. Click on New App and connect your GitHub repository.
  4. Select your branch and main file (app.py).
  5. Click Deploy.

???? Your app will be instantly live and ready to share!

???? Conclusion

Streamlit makes it incredibly easy for Python developers to build beautiful, interactive dashboards and professional reports.

Whether you are creating a quick data visualization prototype or a full business intelligence solution, Streamlit offers the flexibility and speed to bring your ideas to life.

If you are looking to transform your data into powerful web applications with minimal effort, Streamlit is definitely a tool worth exploring!

The source code and the automated deployment workflow for Streamlit Cloud can be found here:

???? https://github.com/dennisdhm7/Streamlit.git


Recent