← All articles

WTF is Streamlit

From the archive: first published on the original PCT WordPress blog on 1 January 2025.

Streamlit is an open-source Python library designed for building interactive web applications for data science and machine learning projects. It allows you to create highly intuitive and visually appealing apps for your data insights, without requiring extensive knowledge of front-end development.

Key Features

  1. Ease of Use:
    • Streamlit lets you create apps using just Python code. There’s no need to learn HTML, CSS, or JavaScript.
    • It’s as simple as writing a Python script; you just use Streamlit’s functions to build the interface.
  2. Real-Time Updates:
    • Any changes in your script are automatically reflected in your app, making development fast and interactive.
  3. Widgets for Interactivity:
    • You can add sliders, dropdowns, buttons, file uploads, and more with minimal code, allowing users to interact with your data.
  4. Data Visualization:
    • Streamlit seamlessly integrates with popular Python libraries like Matplotlib, Plotly, Seaborn, and Altair to display graphs and charts.
    • It supports rendering tables, maps, and dynamic dashboards.
  5. Deployment:
    • You can deploy your Streamlit app easily using services like Streamlit Cloud, AWS, or Docker.

Why Use Streamlit?

  • Rapid Prototyping: Ideal for quickly turning data scripts into shareable apps.
  • Focus on Data: Streamlit abstracts the complexities of web development, letting you focus on your analysis.
  • Collaborative: Share your app with teammates or clients to showcase insights.

How Does It Work?

Here’s an example of a simple Streamlit app:

import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt

# Title and description
st.title("Streamlit Demo")
st.write("This is a simple example of a Streamlit app.")

# File uploader
uploaded_file = st.file_uploader("Upload a CSV file", type="csv")

if uploaded_file:
    data = pd.read_csv(uploaded_file)
    st.write("Data Preview:")
    st.dataframe(data)

    # Plot
    st.write("Simple Plot:")
    fig, ax = plt.subplots()
    data.plot(ax=ax)
    st.pyplot(fig)

Running the App

  1. Install Streamlit: pip install streamlit
  2. Run your script: streamlit run your_script.py
  3. Open your browser at the URL provided (usually http://localhost:8501).

Who Is It For?

  • Data Scientists
  • Machine Learning Engineers
  • Researchers
  • Analysts who want to share data-driven insights.