Using Streamlit as a substitute for Jupyter Notebooks

Charles Copley
1 min readJun 14, 2024

--

Jupyter notebooks perform an important role in a typical data scientists arsenal. They provide a platform for rapid prototyping, sharing of reproducible results, and exploratory analysis. However, notebooks have several serious shortcomings, namely difficulty in establishing version control processes and challenges in peer-review. As everyone that has used notebooks, the easy of use in changing code and cells can also result in zombie variables persisting long after you thought they were gone, causing hard-to-debug issues.

Of course there are workaround to these issues. Code review and version control can be handled through additional packages (https://www.reviewnb.com/) and establishing frequent kernel restarts can avoid zombie variable issues. However, wouldn’t it be nice to be able to avoid these issues in the first place?

Enter Streamlit (https://streamlit.io/). This is mostly advertised as a way of sharing apps and data, however it can easily be used as a framework to replace jupyter notebooks.

You can get started with something as simple as the code below:

import streamlit as st
import pandas as pd

st.write("""
# My first app
Hello *world!*
""")

df = pd.read_csv("my_data.csv")
st.line_chart(df)

Try it out, and keep in mind how this can make your life easier than using notebooks.

--

--

Charles Copley
Charles Copley

No responses yet