This file contains 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
import streamlit as st | |
import numpy as np | |
def paginator(label, items, items_per_page=10, on_sidebar=True): | |
"""Lets the user paginate a set of items. | |
Parameters | |
---------- | |
label : str | |
The label to display over the pagination widget. |
This file contains 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
import streamlit as st | |
import base64 | |
import textwrap | |
def render_svg(svg): | |
"""Renders the given svg string.""" | |
b64 = base64.b64encode(svg.encode('utf-8')).decode("utf-8") | |
html = r'<img src="data:image/svg+xml;base64,%s"/>' % b64 | |
st.write(html, unsafe_allow_html=True) |
This file contains 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
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]) |
This file contains 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
import streamlit as st | |
import pandas as pd | |
@st.cache | |
def load_metadata(): | |
DATA_URL = "https://streamlit-self-driving.s3-us-west-2.amazonaws.com/labels.csv.gz" | |
return pd.read_csv(DATA_URL, nrows=1000) | |
@st.cache | |
def create_summary(metadata, summary_type): |
This file contains 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
import streamlit as st | |
import pandas as pd | |
# Load some example data. | |
DATA_URL = \ | |
"http://s3-us-west-2.amazonaws.com/streamlit-demo-data/uber-raw-data-sep14.csv.gz" | |
data = st.cache(pd.read_csv)(DATA_URL, nrows=1000) | |
# Select some rows using st.multiselect. This will break down when you have >1000 rows. | |
st.write('### Full Dataset', data) |
This file contains 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
import streamlit as st | |
with st.echo(): | |
def on_change(): | |
st.write(f"my_selection **(1)**: `{st.session_state.my_selection}`") | |
my_selection = st.selectbox( | |
"Select something", ["a", "b"], on_change=on_change, key="my_selection" | |
) | |
st.write(f"my_selection **(2)**: `{st.session_state.my_selection}`") |
This file contains 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
import streamlit as st | |
import itertools | |
def paginator(label, items, items_per_page=10, on_sidebar=True): | |
"""Lets the user paginate a set of items. | |
Parameters | |
---------- | |
label : str | |
The label to display over the pagination widget. |
This file contains 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
import streamlit as st | |
import streamlit.ReportThread as ReportThread | |
from streamlit.server.Server import Server | |
import time | |
import functools | |
import random | |
import string | |
# Copied from tvst's great gist: |
This file contains 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
import streamlit as st | |
import spacy | |
from spacy import displacy | |
SPACY_MODEL_NAMES = ["en_core_web_sm", "de_core_news_sm"] | |
DEFAULT_TEXT = "Mark Zuckerberg is the CEO of Facebook." | |
HTML_WRAPPER = """<div style="overflow-x: auto; border: 1px solid #e6e9ef; border-radius: 0.25rem; padding: 1rem">{}</div>""" | |
@st.cache(ignore_hash=True) |
NewerOlder