The most brilliant mathematical model is useless if executives cannot understand or interact with its findings. Streamlit empowers data scientists to transform raw analysis scripts into interactive, production-ready web applications and business intelligence dashboards using 100% pure Python.
# app.py - Run with: streamlit run app.py
import streamlit as st
import pandas as pd
import numpy as np
import plotly.express as px
# Page configuration
st.set_page_config(page_title="Veewom BI Executive Dashboard", layout="wide", page_icon="📊")
st.title("📊 Enterprise Customer Retention & Revenue Analytics")
st.markdown("Interactive executive monitor powered by Python and Streamlit.")
# Cached data loader
@st.cache_data
def load_data():
np.random.seed(42)
return pd.DataFrame({
'region': np.random.choice(['North America', 'Europe', 'Asia-Pacific'], 1000),
'subscription': np.random.choice(['Starter', 'Growth', 'Enterprise'], 1000, p=[0.5, 0.3, 0.2]),
'monthly_revenue': np.random.exponential(scale=180, size=1000) + 20,
'churn_risk': np.random.choice([0, 1], 1000, p=[0.88, 0.12])
})
df = load_data()
# Sidebar interactive filters
st.sidebar.header("Filter Controls")
selected_region = st.sidebar.multiselect("Select Region", options=df['region'].unique(), default=df['region'].unique())
filtered_df = df[df['region'].isin(selected_region)]
# High-Level KPI Summary Cards
col1, col2, col3 = st.columns(3)
col1.metric("Active Subscriptions", f"{len(filtered_df):,}")
col2.metric("Total MRR", f"$ {filtered_df['monthly_revenue'].sum():,.2f}")
col3.metric("Churn Rate", f"{filtered_df['churn_risk'].mean() * 100:.2f}%", delta="-0.8%")
# Visual charts row
chart_col1, chart_col2 = st.columns(2)
with chart_col1:
fig_bar = px.histogram(filtered_df, x='subscription', y='monthly_revenue', color='subscription',
title="Monthly Revenue by Plan Tier", template='plotly_white')
st.plotly_chart(fig_bar, use_container_width=True)
with chart_col2:
fig_box = px.box(filtered_df, x='region', y='monthly_revenue', color='region',
title="Revenue Distribution by Territory", template='plotly_white')
st.plotly_chart(fig_box, use_container_width=True)
st.success("✔ Production dashboard connected to real-time warehouse data feed.")
Save the code above as app.py and execute streamlit run app.py in your activated terminal. Streamlit spins up a local web server (typically on http://localhost:8501) and hot-reloads instantly whenever you edit the file!
Broaden your statistical analysis, Python data wrangling, and production engineering expertise:
Add responsive charts with hover tooltips and zoom to Streamlit apps.
Connect your Streamlit frontend to dedicated backend inference services.
Containerize and deploy your Streamlit dashboard to cloud infrastructure.
Showcase live interactive Streamlit dashboards in your professional portfolio.