tags:
- python
- streamlit
title: What is Streamlit?
permalink: what-is-streamlit
date created: Friday, October 20th 2023, 9:44:08 pm
date modified: Thursday, May 8th 2025, 4:49:33 pm
Streamlit is an open-source Python framework for data scientists and AI/ML engineers to deliver interactive data apps - in only a few lines of code.
Install Streamlit and Watchdog, to observe file changes.
poetry add streamlit watchdog
Chat text input box.
import streamlit as st
st.text_input("Your name", key="name")
# You can access the value at any point with:
st.session_state.name
Show/hide chat controls, like seed, etc.
import streamlit as st
import numpy as np
import pandas as pd
if st.checkbox('Show dataframe'):
chart_data = pd.DataFrame(
np.random.randn(20, 3),
columns=['a', 'b', 'c'])
chart_data
Advanced: Show/hide chat controls
import streamlit as st
# Add a selectbox to the sidebar:
add_selectbox = st.sidebar.selectbox(
'How would you like to be contacted?',
('Email', 'Home phone', 'Mobile phone')
)
# Add a slider to the sidebar:
add_slider = st.sidebar.slider(
'Select a range of values',
0.0, 100.0, (25.0, 75.0)
)
Use st.cache_resource
to cache global resources like ML models and database connections.
st.cache_data
since cached values are stored by reference.