Skip to content

Instantly share code, notes, and snippets.

@duncangh
Forked from treuille/cache_example.py
Created October 6, 2019 02:18
Show Gist options
  • Select an option

  • Save duncangh/51dd162d7fd6cedca32a92ecbb4bf24c to your computer and use it in GitHub Desktop.

Select an option

Save duncangh/51dd162d7fd6cedca32a92ecbb4bf24c 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