ProCodebaseProCodebase
  • ModusA Growth OS for your business, on WhatsAppKiosqSell more. Chase less.AI InterviewerAutomated screening & AI-led interviewsXperto AIAI prep companion for candidatesAI Tools HubResume builder, learning paths & more
  • Pre-Vetted DevelopersScreened, scored and ready to interviewAI-Native DevelopersSenior engineers on an hourly basis
  • Services
  • Features
  • AI Coaching
  • Jobs
  • FAQs
Sign inBook a demo
  • Services
  • Features
  • AI Coaching
  • Jobs
  • FAQs
Sign inBook a demo
ProCodebaseProCodebase

ProCodebase Technologies builds AI products for hiring and growth, and ships software for clients as a technical consultancy. We source, screen and deliver pre-vetted developers — so you only interview high-signal candidates.

Products

  • Modus
  • Kiosq
  • AI Interviewer
  • Xperto AI
  • AI Tools Hub

Hire & build

  • Pre-Vetted Developers
  • AI-Native Developers
  • Technical Consultancy
  • MVP Development
  • Features

Resources

  • Articles
  • Topics
  • Certifications
  • Collections
  • Jobs

Company

  • About Us
  • Contact Us
  • Book a Demo
  • FAQs

© 2026 ProCodebase Technologies. All rights reserved.

  • Privacy Policy
  • Terms & Conditions
  • Refund & Cancellation

Level Up Your Skills with Xperto-AI

A multi-AI agent platform that helps you level up your development skills and ace your interview preparation to secure your dream job.

Launch Xperto-AI

Building Interactive Dashboards with Streamlit

author
Generated by
ProCodebase AI

15/11/2024

python

Sign in to read full article

Introduction to Streamlit

Streamlit is a game-changer in the world of Python-based web applications. It allows data scientists and developers to quickly turn data scripts into shareable web apps without the need for extensive web development experience. Let's dive into how you can leverage Streamlit to build impressive dashboards.

Getting Started with Streamlit

First, you'll need to install Streamlit. Open your terminal and run:

pip install streamlit

Once installed, you can create your first Streamlit app by creating a new Python file, let's call it dashboard.py, and adding the following code:

import streamlit as st st.title("My First Streamlit Dashboard") st.write("Welcome to the world of interactive dashboards!")

To run your app, use the command:

streamlit run dashboard.py

This will launch a local server and open your dashboard in a web browser.

Key Components of a Streamlit Dashboard

1. Data Input and Display

Streamlit makes it easy to load and display data. Here's how you can upload a CSV file and display it:

import pandas as pd import streamlit as st uploaded_file = st.file_uploader("Choose a CSV file", type="csv") if uploaded_file is not None: data = pd.read_csv(uploaded_file) st.write(data)

2. Interactive Widgets

Streamlit offers various widgets to make your dashboard interactive. Let's add a slider to filter our data:

min_value = int(data['Age'].min()) max_value = int(data['Age'].max()) age_filter = st.slider("Filter by Age", min_value, max_value, (min_value, max_value)) filtered_data = data[(data['Age'] >= age_filter[0]) & (data['Age'] <= age_filter[1])] st.write(filtered_data)

3. Data Visualization

Streamlit integrates seamlessly with popular visualization libraries. Here's an example using Plotly:

import plotly.express as px fig = px.scatter(filtered_data, x="Age", y="Salary", color="Department") st.plotly_chart(fig)

Building a Complete Dashboard

Now, let's put it all together to create a more complex dashboard:

import streamlit as st import pandas as pd import plotly.express as px # Page config st.set_page_config(page_title="Employee Dashboard", layout="wide") # Title st.title("Employee Dashboard") # Data loading @st.cache_data def load_data(): return pd.read_csv("employee_data.csv") data = load_data() # Sidebar filters st.sidebar.header("Filters") department = st.sidebar.multiselect("Select Department", options=data["Department"].unique()) age_range = st.sidebar.slider("Age Range", min_value=20, max_value=60, value=(20, 60)) # Apply filters filtered_data = data[ (data["Department"].isin(department) if department else True) & (data["Age"].between(age_range[0], age_range[1])) ] # Main content col1, col2 = st.columns(2) with col1: st.subheader("Employee Count by Department") dept_count = filtered_data["Department"].value_counts() fig1 = px.bar(dept_count, x=dept_count.index, y=dept_count.values) st.plotly_chart(fig1) with col2: st.subheader("Salary Distribution") fig2 = px.box(filtered_data, x="Department", y="Salary") st.plotly_chart(fig2) st.subheader("Employee Details") st.dataframe(filtered_data)

This dashboard includes:

  • A sidebar with filters
  • Two charts displaying department statistics and salary distribution
  • A table showing detailed employee information

Enhancing Your Dashboard

To take your dashboard to the next level, consider these advanced features:

  1. Caching: Use @st.cache_data to speed up data loading and processing.
  2. Custom CSS: Improve the look of your dashboard with custom styles.
  3. Session State: Maintain user interactions across reruns.
  4. Metrics and KPIs: Use st.metric() to display important numbers prominently.

Deployment

Once you're happy with your dashboard, you can deploy it using Streamlit Sharing, Heroku, or any other Python-friendly hosting service.

By following this guide, you've learned the basics of creating interactive dashboards with Streamlit. Keep experimenting with different widgets, layouts, and visualizations to create powerful data applications that can help you and your team make data-driven decisions.

Popular tags

pythonstreamlitdata visualization

Share now!

Like & bookmark

Related collections

  • Mastering NumPy: From Basics to Advanced

    25/09/2024 · Python

  • Mastering Pandas: From Foundations to Advanced Data Engineering

    25/09/2024 · Python

  • LlamaIndex: Data Framework for LLM Apps

    05/11/2024 · Python

  • Mastering Hugging Face Transformers

    14/11/2024 · Python

  • Advanced Python Mastery: Techniques for Experts

    15/01/2025 · Python

Related articles

  • Leveraging Python for Robust Microservices Architecture

    15/01/2025 · Python

  • Python Generators and Iterators Deep Dive

    15/01/2025 · Python

  • Deploying PyTorch Models to Production

    14/11/2024 · Python

  • Unleashing the Power of Metaprogramming

    15/01/2025 · Python

  • Unlocking the Power of Embeddings and Vector Representations in Python with LlamaIndex

    05/11/2024 · Python

  • Mastering File Handling in LangGraph

    17/11/2024 · Python

  • Mastering Clustering Algorithms in Scikit-learn

    15/11/2024 · Python

Popular category

  • Python
  • Generative AI
  • Machine Learning
  • ReactJS
  • System Design