What is Streamlit
What is Streamlit
Streamlit is a Python framework that lets you turn Python code into an interactive web application very quickly.
The simplest mental model is:
Streamlit = an easy way to build a web UI using Python, without needing to learn much HTML, CSS, or JavaScript.
Example
Suppose you have a Python function that predicts house prices:
def predict_price(size, bedrooms):
return size * 3000 + bedrooms * 10000With Streamlit, you can turn that into a little web app:
import streamlit as st
st.title("House Price Predictor")
size = st.number_input("House size")
bedrooms = st.number_input("Bedrooms")
if st.button("Predict"):
price = predict_price(size, bedrooms)
st.write(f"Predicted price: £{price:,.0f}")The result is a webpage with:
┌─────────────────────────────────┐
│ House Price Predictor │
│ │
│ House size: [ 1200 ] │
│ │
│ Bedrooms: [ 3 ] │
│ │
│ [ Predict ] │
│ │
│ Predicted price: £3,630,000 │
└─────────────────────────────────┘You wrote Python, but users interact with it through a web browser.
Why is Streamlit popular?
It's particularly useful for data science and data engineering projects because you can quickly visualize and interact with data.
For example:
import streamlit as st
import pandas as pd
df = pd.read_csv("sales.csv")
st.title("Sales Dashboard")
st.dataframe(df)
st.bar_chart(df.groupby("month")["sales"].sum())You could get a dashboard like:
Sales Dashboard
┌─────────────────────────────┐
│ Sales by Month │
│ │
│ █ │
│ █ █ │
│ █ █ █ █ █ │
│ █ █ █ █ █ █ │
└─────────────────────────────┘
Raw Data
┌──────┬────────┬───────────┐
│ Date │ Product│ Sales │
├──────┼────────┼───────────┤
│ ... │ ... │ ... │
└──────┴────────┴───────────┘Streamlit vs other technologies
These tools have very different purposes:
| Technology | Purpose |
|---|---|
| AWS | Cloud infrastructure |
| Docker | Package/run applications |
| Spark | Process huge datasets |
| Airflow | Schedule/orchestrate workflows |
| Streamlit | Build interactive web apps/dashboards |
| PostgreSQL | Store structured data |
They can actually work together:
AWS
│
┌────────────────┼────────────────┐
│ │ │
S3 Spark PostgreSQL
│ │ │
└────────────────┼────────────────┘
↓
Airflow
orchestrates
│
↓
Streamlit
│
↓
Web DashboardFor example, you could build a data engineering portfolio project where:
Airflow runs a daily pipeline.
Python/Spark processes incoming data.
S3 stores the raw and processed data.
PostgreSQL stores the final results.
Streamlit displays those results in an interactive dashboard.
Docker packages the whole application.
AWS hosts the infrastructure.
That's a very realistic combination of technologies to see in a modern data project.


Comments
Post a Comment