+ - 0:00:00
Notes for current slide
Notes for next slide

Light Up Your Data with Streamlit!



Thomas J. Fan

@thomasjpfan

This talk on Github: thomasjpfan/scipy-2021-streamlit

What is Streamlit?

Allows you to quickly build web applications and dashboards in Python

Three Advantages of Streamlit 🚀

(In my opinion)

Regular Python Files

Compatible with Many Visualizations Libraries

Matplotlib

Plotly

Altair

User interactions are simple to write

import os
import streamlit as st
penguin = st.radio(
"Select a penguin",
options=["adelie", "gentoo", "chinstrap"])
st.header(f"Here is a {penguin}!")
image_path = os.path.join("images",
f"{penguin}.jpeg")
st.image(image_path)

Streamlit's API 💻

Text

Media

User Interactions

Visualization

Layout

import streamlit as st

Demo materials for this talk:

github.com/thomasjpfan/scipy-2021-streamlit-demo

Text 🔠

Text Demo 🔠

  • st.title
  • st.header
  • st.subheader
  • st.write
    • Markdown
    • Math
    • DataFrames

Media 📸

Media Demo 📸

  • st.image
  • st.audio
  • st.video

User Interactions ☎️

User Interactions ☎️

import os
import streamlit as st
penguin = st.radio(
"Select a penguin",
options=["adelie", "gentoo", "chinstrap"])
st.header(f"Here is a {penguin}!")
image_path = os.path.join("images",
f"{penguin}.jpeg")
st.image(image_path)

User Interactions Demo ☎️

  • st.button
  • st.checkbox
  • st.radio
  • st.selectbox
  • st.multiselect
  • st.slider
  • st.select_slider
  • st.text_input
  • st.number_input
  • st.text_area
  • st.date_input
  • st.time_input
  • st.file_uploader
  • st.color_picker

Visualization 📊

Visualization Demo 📊

Matplotlib

Plotly

Altair

Matplotlib: use Object-oriented API 🚨

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1, 2, 3, 4])
ax.set_ylabel('some numbers')
st.write(fig)

Layout 🗄

Layout Demo 🗄

  • st.sidebar
  • st.beta_columns

Performance 🚀

  • st.cache to cache function return values
  • Really useful for data loading
@st.cache
def load_data():
data = pd.read_csv(...)
return data

Building a Machine Learning Dashboard 💻

import streamlit.components.v1 as componenets

Streamlit Components!

Streamlit Components Demo!

Additional Streamlit API

Other Resources to get started!

Light Up Your Data with Streamlit!

  1. Regular Python files
  2. Compatible with Many Visualizations Libraries
  3. User interactions are simple to write

What is Streamlit?

Allows you to quickly build web applications and dashboards in Python

Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow