A cheat sheet for streamlit

Overview

Open in Streamlit

Open in Heroku

Streamlit Cheat Sheet

App to summarise streamlit docs v1.0.0

There is also an accompanying png and pdf version

https://github.com/daniellewisDL/streamlit-cheat-sheet

v1.0.0 October 2021

Author:

Contributors:

Versioning

  • Based on Streamlit 1.0.0
  • Made with Python 3.8.5

Requirements

A clean venv with just pip and then Streamlit

Deployments

Streamlit Cheat Sheet - Streamlit Cloud

Streamlit Cheat Sheet - Heroku

Show me

Streamlit Cheat Sheet


Cheat sheet content

Magic commands

# Magic commands implicitly `st.write()`
''' _This_ is some __Markdown__ '''
a=3
'dataframe:', data

Display text

import streamlit as st

st.text('Fixed width text')
st.markdown('_Markdown_') # see *
st.caption('Balloons. Hundreds of them...')
st.latex(r\'\'\' e^{i\pi} + 1 = 0 \'\'\')
st.write('Most objects') # df, err, func, keras!
st.write(['st', 'is <', 3]) # see *
st.title('My title')
st.header('My header')
st.subheader('My sub')
st.code('for i in range(8): foo()')

* optional kwarg unsafe_allow_html = True

Display data

st.dataframe(my_dataframe)
st.table(data.iloc[0:10])
st.json({'foo':'bar','fu':'ba'})
st.metric(label="Temp", value="273 K", delta="1.2 K")

Display charts

st.line_chart(data)
st.area_chart(data)
st.bar_chart(data)
st.pyplot(fig)
st.altair_chart(data)
st.vega_lite_chart(data)
st.plotly_chart(data)
st.bokeh_chart(data)
st.pydeck_chart(data)
st.deck_gl_chart(data)
st.graphviz_chart(data)
st.map(data)

Display media

st.image('./header.png')
st.audio(data)
st.video(data)

Display interactive widgets

st.button('Hit me')
st.download_button('On the dl', data)
st.checkbox('Check me out')
st.radio('Radio', [1,2,3])
st.selectbox('Select', [1,2,3])
st.multiselect('Multiselect', [1,2,3])
st.slider('Slide me', min_value=0, max_value=10)
st.select_slider('Slide to select', options=[1,'2'])
st.text_input('Enter some text')
st.number_input('Enter a number')
st.text_area('Area for textual entry')
st.date_input('Date input')
st.time_input('Time entry')
st.file_uploader('File uploader')
st.color_picker('Pick a color')

Use widgets' returned values in variables:

>>> for i in range(int(st.number_input('Num:'))): foo()
>>> if st.sidebar.selectbox('I:',['f']) == 'f': b()
>>> my_slider_val = st.slider('Quinn Mallory', 1, 88)
>>> st.write(slider_val)

Control flow

st.stop()

Lay out your app

st.form('my_form_identifier')
st.form_submit_button('Submit to me')
st.container()
st.columns(spec)
col1, col2 = st.columns(2)
col1.subheader('Columnisation')
st.expander('Expander')
with st.expander('Expand'):
    st.write('Juicy deets')

Batch widgets together in a form:

with st.form(key='my_form'):
 	text_input = st.text_input(label='Enter some text')
	submit_button = st.form_submit_button(label='Submit')

Display code

st.echo()
with st.echo():
    st.write('Code will be executed and printed')

Display progress and status

st.progress(progress_variable_1_to_100)
st.spinner()
with st.spinner(text='In progress'):
    time.sleep(5)
    st.success('Done')
st.balloons()
st.error('Error message')
st.warning('Warning message')
st.info('Info message')
st.success('Success message')
st.exception(e)

Placeholders, help, and options

st.empty()
my_placeholder = st.empty()
my_placeholder.text('Replaced!')
st.help(pandas.DataFrame)
st.get_option(key)
st.set_option(key, value)
st.set_page_config(layout='wide')

Mutate data

DeltaGenerator.add_rows(data)
my_table = st.table(df1)
my_table.add_rows(df2)
my_chart = st.line_chart(df1)
my_chart.add_rows(df2)

Optimize performance

@st.cache
>>> @st.cache
... def fetch_and_clean_data(url):
...     # Mutate data at url
...     return data
>>> # Executes d1 as first time
>>> d1 = fetch_and_clean_data(ref1)
>>> # Does not execute d1; returns cached value, d1==d2
>>> d2 = fetch_and_clean_data(ref1)
>>> # Different arg, so function d1 executes
>>> d3 = fetch_and_clean_data(ref2)

Other key parts of the API

Comments
  • Provide cheatsheet in README.md

    Provide cheatsheet in README.md

    The cheatsheet is great, and there are things one my want to try immediately. Maybe provide the commands in README.md - for easier copy-and-try movements?

    opened by epogrebnyak 3
  • Update cheat sheet for 0.71.0

    Update cheat sheet for 0.71.0

    Hey Daniel! Austin from Streamlit here. I'm sure you already know this, but we think your cheat sheet is AMAZING -- so much so, we're now linking to it from the latest version of our docs! (It's currently our most-trafficked Streamlit Sharing app with ~300 daily page views 🥳)

    Anyways, since we just released 0.71.0, I thought I might suggest some tweaks to keep your cheat sheet up to date. Please let me know what you think!

    • Bump version number from 0.68.0 to 0.71.0
    • Remove beta_ tag from st.set_page_config and st.color_picker
    • LInk to beta and experimental page
    • Minor wording/capitalization tweaks
    • Add the "Open in Streamlit" badge to README
    opened by akrolsmir 2
  • Update to 0.86.0

    Update to 0.86.0

    Based on changelog here I'd identify the following things to be done:

    • [ ] 0.81.1 - Addition of st.form() and st.form_submit_button()
    • [ ] 0.81.1 - Addition of st.caption()
    • [ ] 0.84.0 - Addition of st.session_state()
    • [ ] 0.86.0 - You can now use st.columns, st.container and st.expander without the beta_ prefix.
    opened by arnaudmiribel 1
  • Update to 0.86.0

    Update to 0.86.0

    Based on changelog here I'd identify the following things to be done:

    • [x] 0.81.1 - Addition of st.form() and st.form_submit_button() 166ccdd
    • [x] 0.81.1 - Addition of st.caption() 4a77a2d
    • [x] 0.84.0 - Addition of st.session_state() 0050ab6
    • [x] 0.86.0 - You can now use st.columns, st.container and st.expander without the beta_ prefix. 166ccdd

    Also updates the README.md e3c274b

    Closes issue #8

    opened by arnaudmiribel 0
  • Simulated Cheat Sheet

    Simulated Cheat Sheet

    Hello Danielle, I’m Rohan, A Computer Science Student. In the Duration of me working with Streamlit for different projects or ideas the moment I came across your concise cheat sheet made things easier for me to reference various functionalities available. While it being really useful, initially when I was new to streamlit and referring your cheatsheet, I always wondered what would be the rendered widgets look like So, seeing that you've deployed your cheat sheet with streamlit-share, I decided to fork your cheat sheet repo and branch out a section within the application called "Simulated Cheat Sheet" where I carefully organised sections for each streamlit's native functionality and their "rendered view". I believe the novice streamlit users who refer to your cheat-sheet will also be able to acknowledge the post renders of this framework's widgets and text-related functions.

    Change Log

    • Application/Cheatsheet is now segmented into Sections called Descriptive Cheatsheet and Simulated Cheatsheet using st.beta_expander().
    • Descriptive cheatsheet ( your work ) is left untouched.
    • Simulated Cheatsheet will have its own sidebar ( called Control shelf ) where the sections (radio buttons) for Display text, Display Charts, Display Media, Display Widgets, Display Progress and Status are available.
    • Each section will have the method name associated with that section, its parameters and optionally a code snippet for conventional usage or to display the control-flow of the operation using widgets.
    • For Display Media section, I've added a Soundtrack from a movie ( Interstellar ) which in case concerns copyright actions, can be replaced with another one. Video, on the other hand, is taken from a free-source which was also used in streamlit's official documentation site.
    • Total new Files added to the repository are 3; 2 of which are an Audio File and a Video File under Media Directory and the other is a PNG of a HEAD encapsulating a BRAIN in reference to your logo.
    • Editing the requirements.txt file to incorporate libraries numpy, pandas and matplotlib which are used for provided examples

    Preview:

    • Front-Page Front-Page
    • Simulated Cheatsheet Simulated-CS

    Note - Observing your Code format and acknowledging how structured it really is I didn't want to divert the aesthetic by inserting my work so I stuck with your beautiful code organisation and adapted to it as much as possible. The Merge should be a direct fast-forward kind without any Merge-conflicts hindering you with any changes for further to be made. I hope you to accept this contribution, if something from the above seems unconventional, I'm sorry, this is the process through which I want to learn stuff from smarter people like you correcting my mistakes. Thank you;

    opened by r0han99 0
Owner
Daniel Lewis
Daniel Lewis
Streamlit component to display topics from Streamlit's community forum related to any exception.

streamlit-forum Streamlit component to display topics from Streamlit's community forum related to any exception. Installation pip install streamlit-fo

Snehan Kekre 7 Jul 15, 2022
A Google sheet which keeps track of the locations that want to visit and a price cutoff

FlightDeals Here's how the program works. First, I have a Google sheet which keeps track of the locations that I want to visit and a price cutoff. It

Lynne Munini 5 Nov 21, 2022
frida-based ceserver. iOS analysis is possible with Cheat Engine.

frida-ceserver frida-based ceserver. iOS analysis is possible with Cheat Engine. Original by Dark Byte. Usage Install frida on iOS. python main.py Cyd

KenjiroIchise 89 Jan 8, 2023
An osu! cheat made in c++ rewritten in python and currently undetected.

megumi-python An osu! cheat made in c++ rewritten in python and currently undetected. Installation Guide Download python 3.9 from https://python.org C

Elaina 2 Nov 18, 2022
Aides to reduce a cheat file with a personal selection of the cheats you want to use.

Retroarch Cheat File Reducer Description Aides to reduce a cheat file with a personal selection of the cheats you want to use. Instructions Copy a sel

null 1 Jan 9, 2022
Wordless - the #1 app for helping you cheat at Wordle, which is sure to make you popular at parties

Wordless Wordless is the #1 app for helping you cheat at Wordle, which is sure t

James Kirk 7 Feb 4, 2022
🪄 Auto-generate Streamlit UI from Pydantic Models and Dataclasses.

Streamlit Pydantic Auto-generate Streamlit UI elements from Pydantic models. Getting Started • Documentation • Support • Report a Bug • Contribution •

Lukas Masuch 103 Dec 25, 2022
Addons like multipages for streamlit webapp

streamlit_pages Installation $ pip install streamlit-pages Features Adding multiple pages to streamlit Sharing specific pages Usage import streamlit

null 36 Dec 25, 2022
Hydralit package is a wrapping and template project to combine multiple independant Streamlit applications into a multi-page application.

Hydralit The Hydralit package is a wrapping and template project to combine multiple independant (or somewhat dependant) Streamlit applications into a

Jackson Storm 108 Jan 8, 2023
OpenSea NFT API App using Python and Streamlit

opensea-nft-api-tutorial OpenSea NFT API App using Python and Streamlit Tutorial Video Walkthrough https://www.youtube.com/watch?v=49SupvcFC1M Instruc

null 64 Oct 28, 2022
Repo to demo translating colab/jupyter notebook to streamlit webapp

Repo to demo translating colab/jupyter notebook to streamlit webapp

Marisa Smith 2 Feb 2, 2022
Write Streamlit apps using Notion! (Prototype)

Streamlit + Notion test app Write Streamlit apps using Notion! ☠️ IMPORTANT: This is just a little prototype I made to play with some ideas. Not meant

Thiago Teixeira 22 Sep 8, 2022
A streamlit app for exploring image search results from HuggingPics

title emoji colorFrom colorTo sdk app_file pinned huggingpics-explorer ?? blue red streamlit app.py false huggingpics-explorer A streamlit app for exp

Nathan Raw 4 Sep 10, 2022
A simple streamlit webapp with multiple functionality

A simple streamlit webapp with multiple functionality

Omkar Pramod Hankare 2 Nov 24, 2021
📽 Streamlit application powered by a PyScaffold project setup

streamlit-demo Streamlit application powered by a PyScaffold project setup. Work in progress: The idea of this repo is to demonstrate how to package a

PyScaffold 2 Oct 10, 2022
Runtime profiler for Streamlit, powered by pyinstrument

streamlit-profiler ???? Runtime profiler for Streamlit, powered by pyinstrument. streamlit-profiler is a Streamlit component that helps you find out w

Johannes Rieke 23 Nov 30, 2022
Streamlit apps done following data professor's course on YouTube

streamlit-twelve-apps Streamlit apps done following data professor's course on YouTube Español Curso de apps de data science hecho por Data Professor

Federico Bravin 1 Jan 10, 2022
Github Star Tracking app with Streamlit

github-star-tracking-python-app Github Star Tracking app with Streamlit #8daysofstreamlit How to run it locally? Clone or Download & Unzip the Repo En

amrrs 4 Sep 22, 2022