Skip to content

Instantly share code, notes, and snippets.

@shantanuo
Forked from treuille/cache_example.py
Created October 28, 2019 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shantanuo/aeee449a7865f988db2902f124d0ef30 to your computer and use it in GitHub Desktop.
Save shantanuo/aeee449a7865f988db2902f124d0ef30 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])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment