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 * 10000

With 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:

TechnologyPurpose
AWSCloud infrastructure
DockerPackage/run applications
SparkProcess huge datasets
AirflowSchedule/orchestrate workflows
StreamlitBuild interactive web apps/dashboards
PostgreSQLStore structured data

They can actually work together:

                       AWS
                        │
       ┌────────────────┼────────────────┐
       │                │                │
      S3              Spark          PostgreSQL
       │                │                │
       └────────────────┼────────────────┘
                        ↓
                    Airflow
                  orchestrates
                        │
                        ↓
                   Streamlit
                        │
                        ↓
                  Web Dashboard

For example, you could build a data engineering portfolio project where:

  1. Airflow runs a daily pipeline.

  2. Python/Spark processes incoming data.

  3. S3 stores the raw and processed data.

  4. PostgreSQL stores the final results.

  5. Streamlit displays those results in an interactive dashboard.

  6. Docker packages the whole application.

  7. AWS hosts the infrastructure.

That's a very realistic combination of technologies to see in a modern data project.

Learn Python

PCWorkshops  




Comments

Popular posts from this blog

Delete vs Truncate in MySQL and MS SQL Server

Building Cross-Platform JavaFX Apps with Gluon

Companies and real-world applications using JavaFX