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 Scikit-learn from Basics to Advanced

    15/11/2024 · Python

  • LlamaIndex: Data Framework for LLM Apps

    05/11/2024 · Python

  • Mastering NLTK for Natural Language Processing

    22/11/2024 · Python

  • TensorFlow Mastery: From Foundations to Frontiers

    06/10/2024 · Python

  • FastAPI Mastery: From Zero to Hero

    15/10/2024 · Python

Related articles

  • TensorFlow Keras API Deep Dive

    06/10/2024 · Python

  • Exploring Image Processing with Matplotlib

    05/10/2024 · Python

  • Mastering Document Loaders and Text Splitting in LangChain

    26/10/2024 · Python

  • Integrating APIs with Streamlit Applications

    15/11/2024 · Python

  • Streamlining Data Ingestion

    05/11/2024 · Python

  • Mastering Django Signals

    26/10/2024 · Python

  • Enhancing Streamlit Apps with Dynamic Visualizations

    15/11/2024 · Python

Popular category

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