-
-
Save pythoninthegrass/b75d39158f42722a9c25871f8aa4fd20 to your computer and use it in GitHub Desktop.
This demonstrates the st.cache function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# USAGE | |
""" | |
From @treuille: | |
pip install --upgrade streamlit | |
streamlit run https://gist.githubusercontent.com/pythoninthegrass/b75d39158f42722a9c25871f8aa4fd20/raw/2019640b6a9ff5da5ab6d5b11b3345ddc764b285/cache_example.py | |
""" | |
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