Skip to content

Instantly share code, notes, and snippets.

@treuille
Created September 30, 2019 18:52
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save treuille/c633dc8bc86efaa98eb8abe76478aa81 to your computer and use it in GitHub Desktop.
Save treuille/c633dc8bc86efaa98eb8abe76478aa81 to your computer and use it in GitHub Desktop.
This demonstrates the st.cache function
import streamlit as st
import pandas as pd
# Reuse this data across runs!
read_and_cache_csv = st.cache(pd.read_csv)
BUCKET = "https://streamlit-self-driving.s3-us-west-2.amazonaws.com/"
data = read_and_cache_csv(BUCKET + "labels.csv.gz", nrows=1000)
desired_label = st.selectbox('Filter to:', ['car', 'truck'])
st.write(data[data.label == desired_label])
@treuille
Copy link
Author

You can run this gist directly from the command line with:

pip install --upgrade streamlit
streamlit run https://gist.githubusercontent.com/treuille/c633dc8bc86efaa98eb8abe76478aa81/raw/2019640b6a9ff5da5ab6d5b11b3345ddc764b285/cache_example.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment