Data

Streamlit - build data dashboards in minutes for free

Christoph Thale|
#Streamlit#Python#AI

Data visualization is a crucial aspect of data analysis helping teams make informed decisions quickly. With Streamlit, you can build interactive and beautiful dashboards in just a few lines of Python code. No need for web frontend skills or expensive vendor tools like Power BI.

In this post, we’ll walk through a simple Streamlit app that visualizes engineering commit activity over a range of days using a dataset.

What is Streamlit?

Streamlit is an open-source Python framework that makes it incredibly easy to build web apps for data science and machine learning projects. Unlike traditional web development frameworks, Streamlit eliminates the need for HTML, CSS, and JavaScript, allowing you to focus purely on Python code.

Some key advantages of Streamlit:

  • Super simple syntax – You write Python, and Streamlit handles the rest.
  • Automatic UI generation – Widgets and layouts are created dynamically.
  • Live updates – The UI updates instantly when you change your code.
  • Seamless integration with data science tools – Works well with pandas, Matplotlib, Plotly, and more.

Building a Streamlit Dashboard

Let’s create a basic Streamlit app that visualizes the number of commits one engineer has made over a range of days. Install Streamlit If you haven’t already installed Streamlit, you can do so using pip:

pip install streamlit

The Python Code

Here’s a simple Streamlit script that reads a dataset (my_data.csv)

day,commits
0,5
1,4
2,4
3,5
4,5
5,3
6,5
7,4
8,6
9,7

and allows the user to filter data by a range of days, and plots a line chart.

Save this code in a file named my_first_app.py:

import streamlit as st
import pandas as pd

# Load dataset
df = pd.read_csv("my_data.csv")

# Set title of the app
st.title("My first streamlit app")

st.write("""
  This dashboard shows how many commits an engineer has made in a range of days.
  ----
""")

# Create a slider to select a range of days
min_day = df["day"].min()
max_day = df["day"].max()

days = st.slider("Select a range of days", min_day, max_day, (3, 8))

# Filter the dataset based on the selected range
df_filtered = df[(df["day"] >= days[0]) & (df["day"] <= days[1])]

# Display the selected range
st.write("Selected days:", days)

# Plot the line chart
st.line_chart(df_filtered, x="day", y="commits")

Running the App

To launch the Streamlit app, navigate to the directory where your script is saved and run:

streamlit run my_first_app.py

Output of the terminal when launching streamlit locally

Within seconds, your browser will open automatically, displaying an interactive dashboard where you can select a range of days and see how commit activity changes over time.

Visualization of the streamlit app's output displaying a slider, the text for the slider and a chart with the selected data

Why Use Streamlit?

  • Minimal code, maximum functionality – The above example is built with fewer than 20 lines of code.
  • Interactive and engaging – Users can interact with the data using widgets like sliders.
  • Quick deployment – You can deploy Streamlit apps easily using services like Streamlit Community Cloud, using Docker or let it run in Kubernetes.
  • Perfect for data scientists and analysts – No front-end experience required.
  • Open Source - it is just awesome what we get for free.

Finally, I wish you a pleasant journey building your own beautiful Streamlit dashboards and I will see you in the next blog article.

Back to Blog