Mito
Mito for Streamlit
  • Mito Documentation
  • Getting Started
    • Installing Mito
      • Fixing Common Install Errors
      • Installing Mito in a Docker Container
      • Installing Mito for Streamlit
      • Installing Mito for Dash
      • Installing Mito in a Jupyter Notebook Directly
      • Installing Mito in Vertex AI
      • Setting Up a Virtual Environment
  • Data Copilot
    • Data Copilot Core Concepts
    • Agent
    • Chat
    • Autocomplete
    • Smart Debugging
    • Configuration Options
    • AI Data Usage FAQ
  • Mito Spreadsheet
    • Core Concepts
    • Creating a Mitosheet
      • Open Existing Virtual Environments
    • Importing Data
      • Importing CSV Files
      • Importing from Excel Files
      • Importing Dataframes
      • Importing from a remote drive
      • Import: Generated UI from any Python Function
      • Importing from other sources
    • Graphing
      • Graph Creation
      • Graph Styling
      • Graph Export
    • Pivoting/Group By
    • Filter
      • Filter By Condition
      • Filter By Value
    • Mito AI
    • Summary Statistics
    • Type Changes
    • Spreadsheet Formulas
      • Custom Spreadsheet Functions
      • Formula Reference
      • Using VLOOKUP
    • Editing Individual Cells
    • Combining Dataframes
      • Merge (horizontal)
      • Concatenate (horizontal)
      • Anti-merge (unique)
    • Sort Data
    • Split Text to Columns
    • Deleting Columns
    • Deleting Rows
    • Column Headers
      • Editing Column Headers
      • Promote Row to Header
    • Deduplicate
    • Fill NaN Values
    • Transpose
    • Reset Index
    • Unpivot a Dataframe (Melt)
    • Formatting
      • Column Formatting
      • Dataframe Colors
      • Conditional Formatting
    • Exporting Data
      • Download as CSV
      • Download as Excel
      • Generate code to create Excel and CSV reports
    • Using the Generated Code
      • Turn generated code into functions
    • Changing Imported Data
    • Code Snippets
    • Custom Editors: Autogenerate UI from Any Function
    • Find and Replace
    • Bulk column header edits
    • Code Options
    • Scheduling your Automation
    • Keyboard Shortcuts
    • Upgrading Mito
    • Enterprise Logging
  • Mito for Streamlit
    • Getting Started with Mito for Streamlit
    • Streamlit Overview
    • Create a Mito for Streamlit App
    • API Reference
      • Understanding import_folder
      • RunnableAnalysis class
      • Column Definitions
    • Streamlit App Gallery
    • Experienced Streamlit Users
    • Common Design Patterns
      • Deploying Mito for Streamlit in a Docker Image
      • Using Mito for Final Mile Data Cleaning
  • Mito for Dash
    • Getting Started
    • Dash Overview
    • Your First Dash App with Mito
    • Mito vs. Other Dash Components
    • API Reference
      • Understanding import_folder
    • Dash App Gallery
    • Common Design Patterns
      • Refresh Sheet Data Periodically
      • Change Sheet Data from a Select
      • Filter Other Elements to Data Selected in Mito
      • Graph New Data after Edits to Mito
      • Set Mito Spreadsheet Theme
  • Tutorials
    • Pass a dataframe into Mito
    • Create a line chart of time series data
    • Delete Columns with Missing Values
    • Split a column on delimiter
    • Rerun analysis on new data
    • Calculate the difference between rows
    • Calculate each cell's percent total of column
    • Import multiple tables from one Excel sheet
    • Share Mito Spreadsheets Across Users
  • Misc
    • Release Notes
      • April 15 - Now Streaming (0.1.18)
      • March 21 - Smarter, Faster, Stronger Agents
      • February 25 - Agent Mode QoL Improvements
      • February 18 - Mito Agents
      • January 2nd - Inline Completions Arrive
      • December 6th - Smarter Workflow
      • November 27th - @ Mentions, Mito AI Server
      • November 4th, 2024 - Hello Mito AI
      • October 8, 2024 - JupyterLab 4
      • Aug 29th, 2024
      • June 12, 2024
      • March 19, 2024
      • March 13th, 2024
      • February 12th, 2024: Graphing Improvements
      • January 25th, 2024
      • January 5th, 2023: Keyboard Shortcuts
      • December 6, 2023: New Context Menu
      • November 28, 2023: Mito's New Toolbar
      • November 7, 2023: Multiplayer Dash
      • October 23, 2023: RunnableAnalysis class
      • October 16, 2023: Mito for Dash, Custom Editors
      • September 29, 2023: VLOOKUP and Find and Replace!
      • September 7, 2023
      • August 2, 2023: Mito for Streamlit!
      • July 10, 2023
      • May 31, 2023: Mito AI Recon
      • May 19, 2023: Mito AI Chat!
      • April 27, 2023: Generate Functions, Performance improvements, bulk column header transformations
      • April 18, 2023: Cell Editor Improvements, BYO Large Language Model, and more
      • April 10, 2023: AI Access, Excel-like Cell Editor, Performance Improvements
      • April 5, 2023: Range formulas, Pandas 2.0, Snowflake Views
      • March 29, 2023: Excel Range Import Improvements
      • March 14, 2023: Mito AI, Public Interface Versioning
      • February 28, 2023: In-place Pivot Errors
      • February 7, 2023: Excel-like Formulas, Snowflake Import
      • January 23, 2023: Excel range importing
      • January 8, 2023: Custom Code snippets
      • December 26, 2022: Code snippets and bug fixes
      • December 12, 2022: Group Dates in Pivot Tables, Reduced Dependencies
      • November 15, 2022: Filter in Pivot
      • November 9, 2022: Import and Enterprise Config
      • October 31, 2022: Replay Analysis Improvements
      • Old Release Notes
      • August 10, 2023: Export Formatting to Excel
    • Mito Enterprise Features
    • FAQ
    • Terms of Service
    • Privacy Policy
  • Mito
Powered by GitBook

© Mito

On this page
  • Create your first app
  • Add a Mitosheet
  • Use the Mitosheet to Clean the Dataset
  • Use the Mitosheet to Create a Pivot Table
  • Putting it all together
  • Share your app

Was this helpful?

  1. Mito for Streamlit

Create a Mito for Streamlit App

A Quickstart guide to creating your first Streamlit app with the Mito Spreadsheet.

PreviousStreamlit OverviewNextAPI Reference

Last updated 8 months ago

Was this helpful?

Make sure you've installed before continuing.

The easiest way to create your first Streamlit application with Mito is to try things yourself. Streamlit has an awesome developer story, so for each edit you make to your code, you can just refresh the page and see your new changes.

In this guide, we're going to use Mito for Streamlit to create an interactive app that allows users to explore Tesla stock data. We'll do some basic data cleaning, and then perform an analysis that computes the traded volume in the most recent month.

To see the finished script, .

Create your first app

  1. First, create a new Python script. Let's call it stock_data.py

  2. Open stock_data.py in your favorite IDE or text editor, then add these lines:

    import streamlit as st
    from mitosheet.streamlit.v1 import spreadsheet
  3. Let's make the page wide, and set a title:

    st.set_page_config(layout="wide")
    st.title('Tesla Stock Volume Analysis')
  4. Now, run your Streamlit app from the command line:

    streamlit run stock_data.py
  5. The Streamlit app should open in a new tab in your web-browser. Check out that awesome title!

Add a Mitosheet

  1. Now, let's use the Mito spreadsheet to display

    CSV_URL = 'https://raw.githubusercontent.com/plotly/datasets/master/tesla-stock-price.csv'
    new_dfs, code = spreadsheet(CSV_URL)
  2. You'll see a few buttons in the upper-right corner of your app asking if you'd like to rerun the app. Choose Always rerun, and you'll see your changes automatically each time you save the stock_data.py file.

  3. When your app refreshes, you will see the Mito spreadsheet with Tesla stock data. Scroll around like you would in any other spreadsheet!

  4. The return value of the spreadsheet is each of the tabs of the spreadsheet, as well as the code that corresponds to the edits you make in the spreadsheet. Let's display both:

    st.write(new_dfs)
    st.code(code)

Use the Mitosheet to Clean the Dataset

  1. Take a closer look at this dataset. It looks like the first row has an invalid date. Let's remove it from our analysis by right clicking on the row label 0 and then clicking Delete Rows.

  2. Turn the Date column into a datetime. Click the Filter icon next to the Date header, and in the taskpane that opens, use the Dtype dropdown to select datetime.

  3. Pause here and check out the dataframes displayed below the Mitosheet. Note that each

  4. Turn the Volume column into a float. Click the Filter icon next to the Volume header, and in the taskpane that opens, use the Dtype dropdown to select float.

Use the Mitosheet to Create a Pivot Table

We're now ready to use more of Mito's advanced functionality. Let's create a pivot table that allows us to understand how the traded volume has changed over time.

  1. Click the Pivot button in the Mito toolbar.

  2. Add Date to the Rows section. Group date by year-month, so we can understand volume changes on a monthly lee.

  3. Add Volume to the Values section. Select an aggregation type of sum.

    1. If you cannot select sum for Volume, you may have forgotten to change Volume to a float. See step 4 in the section above.

  4. This pivot table now displayes the total of traded volume per month. If you scroll below, you will see that this pivot table is returned from the Mito spreadsheet, and the code to generate this pivot table is returned as well.

Putting it all together

That's it, you made your first app with Mito for Streamlit. Here's our finished script:

import streamlit as st
from mitosheet.streamlit.v1 import spreadsheet

st.set_page_config(layout="wide")
st.title('Tesla Stock Volume Analysis')

CSV_URL = 'https://raw.githubusercontent.com/plotly/datasets/master/tesla-stock-price.csv'
new_dfs, code = spreadsheet(CSV_URL)

st.write(new_dfs)
st.code(code)

Share your app

After you’ve built an app using Mito for Streamlit, it's time to share it! To show it off to the world you can use Streamlit Community Cloud to deploy, manage, and share your app for free.

It works in 3 simple steps:

  1. Put your app in a public GitHub repo (and make sure it has a requirements.txt!)

  2. Click 'Deploy an app' and then paste in your GitHub URL

See the rest of our documentation to see what other functionality is available in Mito, or continue to our to get ideas for how to use Mito in your Streamlit applications.

Sign into

That's it! You now have a publicly deployed app that you can share with the world. Click to learn more about .

App Gallery
share.streamlit.io
how to use Streamlit Community Cloud
Mito for Streamlit
scroll down