Connect with us

Jobs & Careers

How to Combine Streamlit, Pandas, and Plotly for Interactive Data Apps

Published

on


How to Combine Streamlit, Pandas, and Plotly for Interactive Data Apps
Image by Author | ChatGPT

 

Introduction

 
Creating interactive web-based data dashboards in Python is easier than ever when you combine the strengths of Streamlit, Pandas, and Plotly. These three libraries work seamlessly together to transform static datasets into responsive, visually engaging applications — all without needing a background in web development.

However, there’s an important architectural difference to understand before we begin. Unlike libraries such as matplotlib or seaborn that work directly in Jupyter notebooks, Streamlit creates standalone web applications that must be run from the command line. You’ll write your code in a text-based IDE like VS Code, save it as a .py file, and run it using streamlit run filename.py. This shift from the notebook environment to script-based development opens up new possibilities for sharing and deploying your data applications.

In this hands-on tutorial, you’ll learn how to build a complete sales dashboard in two clear steps. We’ll start with core functionality using just Streamlit and Pandas, then enhance the dashboard with interactive visualizations using Plotly.

 

Setup

 
Install the required packages:

pip install streamlit pandas plotly

 

Create a new folder for your project and open it in VS Code (or your preferred text editor).

 

Step 1: Streamlit + Pandas Dashboard

 
Let’s start by building a functional dashboard using just Streamlit and Pandas. This demonstrates how Streamlit creates interactive web interfaces and how Pandas handles data filtering.

Create a file called step1_dashboard_basic.py:

import streamlit as st
import pandas as pd
import numpy as np

# Page config
st.set_page_config(page_title="Basic Sales Dashboard", layout="wide")

# Generate sample data
np.random.seed(42)
df = pd.DataFrame({
    'Date': pd.date_range('2024-01-01', periods=100),
    'Sales': np.random.randint(500, 2000, size=100),
    'Region': np.random.choice(['North', 'South', 'East', 'West'], size=100),
    'Product': np.random.choice(['Product A', 'Product B', 'Product C'], size=100)
})

# Sidebar filters
st.sidebar.title('Filters')
regions = st.sidebar.multiselect('Select Region', df['Region'].unique(), default=df['Region'].unique())
products = st.sidebar.multiselect('Select Product', df['Product'].unique(), default=df['Product'].unique())

# Filter data
filtered_df = df[(df['Region'].isin(regions)) & (df['Product'].isin(products))]

# Display metrics
col1, col2, col3 = st.columns(3)
col1.metric("Total Sales", f"${filtered_df['Sales'].sum():,}")
col2.metric("Average Sales", f"${filtered_df['Sales'].mean():.0f}")
col3.metric("Records", len(filtered_df))

# Display filtered data
st.subheader("Filtered Data")
st.dataframe(filtered_df)

 

Let’s break down the key Streamlit methods used here:

  • st.set_page_config() configures the browser tab title and layout
  • st.sidebar creates the left navigation panel for filters
  • st.multiselect() generates dropdown menus for user selections
  • st.columns() creates side-by-side layout sections
  • st.metric() displays large numbers with labels
  • st.dataframe() renders interactive data tables

These methods automatically handle user interactions and trigger app updates when selections change.

Run this from your terminal (or VS Code’s integrated terminal):

streamlit run step1_dashboard_basic.py

 

Your browser will open to http://localhost:8501 showing an interactive dashboard.

 
How to Combine Streamlit, Pandas, and Plotly for Interactive Data Apps
 

Try changing the filters in the sidebar — watch how the metrics and data table update automatically! This demonstrates the reactive nature of Streamlit combined with Pandas’ data manipulation capabilities.

 

Step 2: Add Plotly for Interactive Visualizations

 
Now let’s enhance our dashboard by adding Plotly’s interactive charts. This shows how all three libraries work together seamlessly. Let’s create a new file and call it step2_dashboard_plotly.py:

import streamlit as st
import pandas as pd
import plotly.express as px
import numpy as np

# Page config
st.set_page_config(page_title="Sales Dashboard with Plotly", layout="wide")

# Generate data
np.random.seed(42)
df = pd.DataFrame({
    'Date': pd.date_range('2024-01-01', periods=100),
    'Sales': np.random.randint(500, 2000, size=100),
    'Region': np.random.choice(['North', 'South', 'East', 'West'], size=100),
    'Product': np.random.choice(['Product A', 'Product B', 'Product C'], size=100)
})

# Sidebar filters
st.sidebar.title('Filters')
regions = st.sidebar.multiselect('Select Region', df['Region'].unique(), default=df['Region'].unique())
products = st.sidebar.multiselect('Select Product', df['Product'].unique(), default=df['Product'].unique())

# Filter data
filtered_df = df[(df['Region'].isin(regions)) & (df['Product'].isin(products))]

# Metrics
col1, col2, col3 = st.columns(3)
col1.metric("Total Sales", f"${filtered_df['Sales'].sum():,}")
col2.metric("Average Sales", f"${filtered_df['Sales'].mean():.0f}")
col3.metric("Records", len(filtered_df))

# Charts
col1, col2 = st.columns(2)

with col1:
    fig_line = px.line(filtered_df, x='Date', y='Sales', color="Region", title="Sales Over Time")
    st.plotly_chart(fig_line, use_container_width=True)

with col2:
    region_sales = filtered_df.groupby('Region')['Sales'].sum().reset_index()
    fig_bar = px.bar(region_sales, x='Region', y='Sales', title="Total Sales by Region")
    st.plotly_chart(fig_bar, use_container_width=True)

# Data table
st.subheader("Filtered Data")
st.dataframe(filtered_df)

 

Run this from your terminal (or VS Code’s integrated terminal):

streamlit run step2_dashboard_plotly.py

 

Now you have a complete interactive dashboard!

 
How to Combine Streamlit, Pandas, and Plotly for Interactive Data Apps
 

The Plotly charts are fully interactive — you can hover over data points, zoom in on specific time periods, and even click legend items to show/hide data series.

 

How the Three Libraries Work Together

 
This combination is powerful because each library handles what it does best:

Pandas manages all data operations:

  • Creating and loading datasets
  • Filtering data based on user selections
  • Aggregating data for visualizations
  • Handling data transformations

Streamlit provides the web interface:

  • Creates interactive widgets (multiselect, sliders, etc.)
  • Automatically reruns the entire app when users interact with widgets
  • Handles the reactive programming model
  • Manages layout with columns and containers

Plotly creates rich, interactive visualizations:

  • Charts that users can hover, zoom, and explore
  • Professional-looking graphs with minimal code
  • Automatic integration with Streamlit’s reactivity

 

Key Development Workflow

 
The development process follows a straightforward pattern. Start by writing your code in VS Code or any text editor, saving it as a .py file. Next, run the application from your terminal using streamlit run filename.py, which opens your dashboard in a browser at http://localhost:8501. As you edit and save your code, Streamlit automatically detects changes and offers to rerun the application. Once you’re satisfied with your dashboard, you can deploy it using Streamlit Community Cloud to share with others.

 

Next Steps

 
Try these enhancements:

Add real data:

# Replace sample data with CSV upload
uploaded_file = st.sidebar.file_uploader("Upload CSV", type="csv")
if uploaded_file:
    df = pd.read_csv(uploaded_file)

 

Keep in mind that real datasets will require preprocessing steps specific to your data structure. You’ll need to adjust column names, handle missing values, and modify the filter options to match your actual data fields. The sample code provides a template, but each dataset will have unique requirements for cleaning and preparation.

More chart types:

# Pie chart for product distribution
fig_pie = px.pie(filtered_df, values="Sales", names="Product", title="Sales by Product")
st.plotly_chart(fig_pie)

 

You can leverage an entire gallery of Plotly’s graphing capabilities.

 

Deploying Your Dashboard

 
Once your dashboard is working locally, sharing it with others is straightforward through Streamlit Community Cloud. First, push your code to a public GitHub repository, making sure to include a requirements.txt file listing your dependencies (streamlit, pandas, plotly). Then visit https://streamlit.io/cloud, sign in with your GitHub account, and select your repository. Streamlit will automatically build and deploy your app, providing a public URL that anyone can access. The free tier supports multiple apps and handles reasonable traffic loads, making it perfect for sharing dashboards with colleagues or showcasing your work in a portfolio.

 

Conclusion

 
The combination of Streamlit, Pandas, and Plotly transforms data analysis from static reports into interactive web applications. With just two Python files and a handful of methods, you’ve built a complete dashboard that rivals expensive business intelligence tools.

This tutorial demonstrates a significant shift in how data scientists can share their work. Instead of sending static charts or requiring colleagues to run Jupyter notebooks, you can now create web applications that anyone can use through a browser. The transition from notebook-based analysis to script-based applications opens new opportunities for data professionals to make their insights more accessible and impactful.

As you continue building with these tools, consider how interactive dashboards can replace traditional reporting in your organization. The same principles you’ve learned here scale to handle real datasets, complex calculations, and sophisticated visualizations. Whether you’re creating executive dashboards, exploratory data tools, or client-facing applications, this three-library combination provides a solid foundation for professional data applications.
 
 

Born in India and raised in Japan, Vinod brings a global perspective to data science and machine learning education. He bridges the gap between emerging AI technologies and practical implementation for working professionals. Vinod focuses on creating accessible learning pathways for complex topics like agentic AI, performance optimization, and AI engineering. He focuses on practical machine learning implementations and mentoring the next generation of data professionals through live sessions and personalized guidance.



Source link

Continue Reading
Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Jobs & Careers

HCLSoftware Launches Domino 14.5 With Focus on Data Privacy and Sovereign AI

Published

on


HCLSoftware, a global enterprise software leader, launched HCL Domino 14.5 on July 7 as a major upgrade, specifically targeting governments and organisations operating in regulated sectors that are concerned about data privacy and digital independence.

A key feature of the new release is Domino IQ, a sovereign AI extension built into the Domino platform. This new tool gives organisations full control over their AI models and data, helping them comply with regulations such as the European AI Act.

 It also removes dependence on foreign cloud services, making it easier for public sector bodies and banks to protect sensitive information.

“The importance of data sovereignty and avoiding unnecessary foreign government influence extends beyond SaaS solutions and AI. Specifically for collaboration – the sensitive data within email, chat, video recordings and documents. With the launch of Domino+ 14.5, HCLSoftware is helping over 200+ government agencies safeguard their sensitive data,” said Richard Jefts, executive vice president and general manager at HCLSoftware

The updated Domino+ collaboration suite now includes enhanced features for secure messaging, meetings, and file sharing. These tools are ready to deploy and meet the needs of organisations that handle highly confidential data.

The platform is supported by IONOS, a leading European cloud provider. Achim Weiss, CEO of IONOS, added, “Today, more than ever, true digital sovereignty is the key to Europe’s digital future. That’s why at IONOS we are proud to provide the sovereign cloud infrastructure for HCL’s sovereign collaboration solutions.”

Other key updates in Domino 14.5 include achieving BSI certification for information security, the integration of security event and incident management (SEIM) tools to enhance threat detection and response, and full compliance with the European Accessibility Act, ensuring that all web-based user experiences are inclusive and accessible to everyone.

With the launch of Domino 14.5, HCLSoftware is aiming to be a trusted technology partner for public sector and highly regulated organisations seeking control, security, and compliance in their digital operations.



Source link

Continue Reading

Jobs & Careers

Mitsubishi Electric Invests in AI-Assisted PLM Systems Startup ‘Things’

Published

on


Mitsubishi Electric Corporation announced on July 7 that its ME Innovation Fund has invested in Things, a Japan-based startup that develops and provides AI-assisted product lifecycle management (PLM) systems for the manufacturing industry. 

This startup specialises in comprehensive document management, covering everything from product planning and development to disposal. According to the company, this marks the 12th investment made by Mitsubishi’s fund to date.

Through this investment, Mitsubishi Electric aims to combine its extensive manufacturing and control expertise with Things’ generative AI technology. The goal is to accelerate the development of digital transformation (DX) solutions that tackle various challenges facing the manufacturing industry.

In recent years, Japan’s manufacturing sector has encountered several challenges, including labour shortages and the ageing of skilled technicians, which hinder the transfer of expertise. In response, DX initiatives, such as the implementation of PLM and other digital systems, have progressed rapidly. However, these initiatives have faced challenges related to development time, cost, usability, and scalability.

Komi Matsubara, an executive officer at Mitsubishi Electric Corporation, stated, “Through our collaboration with Things, we expect to generate new value by integrating our manufacturing expertise with Things’ generative AI technology. We aim to leverage this initiative to enhance the overall competitiveness of the Mitsubishi Electric group.”

Things launched its ‘PRISM’ PLM system in May 2023, utilising generative AI to improve the structure and usage of information in manufacturing. PRISM offers significant cost and scalability advantages, enhancing user interfaces and experiences while effectively implementing proofs of concept across a wide range of companies.

Atsuya Suzuki, CEO of Things, said, “We are pleased to establish a partnership with Mitsubishi Electric through the ME Innovation Fund. By combining our technology with Mitsubishi Electric’s expertise in manufacturing and control, we aim to accelerate the global implementation of pioneering DX solutions for manufacturing.”



Source link

Continue Reading

Jobs & Careers

AI to Track Facial Expressions to Detect PTSD Symptoms in Children

Published

on


A research team from the University of South Florida (USF) has developed an AI system that can identify post-traumatic stress disorder (PTSD) in children.

The project addresses a longstanding clinical dilemma: diagnosing PTSD in children who may not have the emotional vocabulary, cognitive development or comfort to articulate their distress. Traditional methods such as subjective interviews and self-reported questionnaires often fall short. This is where AI steps in.

“Even when they weren’t saying much, you could see what they were going through on their faces,” Alison Salloum, professor at the USF School of Social Work, reportedly said. Her observations during trauma interviews laid the foundation for collaboration with Shaun Canavan, an expert in facial analysis at USF’s Bellini College of Artificial Intelligence, Cybersecurity, and Computing.

The study introduces a privacy-first, context-aware classification model that analyses subtle facial muscle movements. However, instead of using raw footage, the system extracts non-identifiable metrics such as eye gaze, mouth curvature, and head position, ensuring ethical boundaries are respected when working with vulnerable populations. 

“We don’t use raw video. We completely get rid of subject identification and only keep data about facial movement,” Canavan reportedly emphasised. The AI also accounts for conversational context, whether a child is speaking to a parent or a therapist, which significantly influences emotional expressivity.

Across 18 therapy sessions, with over 100 minutes of footage per child and approximately 185,000 frames each, the AI identified consistent facial expression patterns in children diagnosed with PTSD. Notably, children were more expressive with clinicians than with parents; a finding that aligns with psychological literature suggesting shame or emotional avoidance often inhibits open communication at home.

While still in its early stages, the tool is not being pitched as a replacement for therapists. Instead, it’s designed as a clinical augmentation, a second set of ‘digital’ eyes that can pick up on emotional signals even trained professionals might miss in real time.

“Data like this is incredibly rare for AI systems,” Canavan added. “That’s what makes this so promising. We now have an ethically sound, objective way to support mental health assessments.”

If validated on a larger scale, the system could transform mental health diagnostics for children—especially for pre-verbal or very young patients—by turning non-verbal cues into actionable insights. 



Source link

Continue Reading

Trending