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 matplotlib.pyplot as plt | |
import numpy as np | |
import streamlit as st | |
import time | |
fig, ax = plt.subplots() | |
max_x = 5 | |
max_rand = 10 |
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 dash | |
import dash_core_components as dcc | |
import dash_html_components as html | |
from dash.dependencies import Input, Output | |
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] | |
app = dash.Dash(__name__, external_stylesheets=external_stylesheets) | |
app.layout = html.Div([ |
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 | |
import numpy as np | |
def display_dataframe_quickly(df, max_rows=5000, **st_dataframe_kwargs): | |
"""Display a subset of a DataFrame or Numpy Array to speed up app renders. | |
Parameters | |
---------- | |
df : DataFrame | ndarray |
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 | |
from io import BytesIO | |
import matplotlib.pyplot as plt | |
def render_latex(formula, fontsize=12, dpi=300): | |
"""Renders LaTeX formula into Streamlit.""" | |
fig = plt.figure() | |
text = fig.text(0, 0, '$%s$' % formula, fontsize=fontsize) | |
fig.savefig(BytesIO(), dpi=dpi) # triggers rendering |
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 | |
import numpy as np | |
n_points = 1000 | |
sf_lat, sf_lon = 37.76, -122.4 | |
map_data = pd.DataFrame({ | |
'lat': np.random.randn(n_points) / 50 + sf_lat, | |
'lon': np.random.randn(n_points) / 50 + sf_lon, | |
'colorR': np.random.uniform(size=n_points, high=255.0), |
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 functools | |
def partial_cache(func=None, **cache_kwargs): | |
"""Like st.cache, but if the function returns None, then nothing is cached. | |
Parameters | |
---------- | |
func : Callable |
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 pandas as pd | |
DATA_BUCKET = "http://s3-us-west-2.amazonaws.com/streamlit-demo-data/" | |
DATA_URL = DATA_BUCKET + "uber-raw-data-sep14.csv.gz" | |
read_and_cache_csv = st.cache(pd.read_csv) | |
data = read_and_cache_csv(DATA_URL, nrows=100000) | |
st.write('Data', 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 | |
import pandas as pd | |
with st.echo(): | |
@st.cache(ignore_hash=True) | |
def load_cached(): | |
csv = pd.read_csv("http://s3-us-west-2.amazonaws.com/streamlit-demo-data/uber-raw-data-sep14.csv.gz", nrows=100000) | |
return csv | |
df = load_cached() |
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
# -*- coding: utf-8 -*- | |
# Copyright 2018-2019 Streamlit Inc. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software |