Pass a dataframe into Mito
Query a database, or scrape a table from a website and import the dataframe into Mito. Import any Pandas dataframe into Mito.
Import Python Packages
To import a dataframe into Mito, we need the Mito and pandas packages. Both are distributed through the Mito installer. If you have not yet installed Mito, follow the instructions here.
# Import Python packages
import mitosheet
import pandas as pd
Create the Pandas Dataframes
Using Pandas, you can create dataframes by reading csv files, Excel files, or even querying an SQL database.
For the purposes of this tutorial, we will create two sample dataframes.
# Create some simple data to display
train_stations = pd.DataFrame({'Zip': [21001, 97321, 49224, 87102, 24910, 22301], 'City': ['Aberdeen', 'Albany', 'Albion', 'Albuquerque', 'Alderson', 'Alexandria'], 'State': ['MD', 'OR', 'MI', 'NM', 'WV', 'VA'], 'Ticket_Office': ['N', 'Y', 'N', 'Y', 'N', 'Y']})
demographics = pd.DataFrame({'Zip': [21001, 97321, 49224, 87102, 24910, 22301], 'Median_Income': [53979.0, 112924.0, 37556.0, 28388.0, 30914.0, 54087.0], 'Mean_Income': [66169.0, 147076.0, 50371.0, 39529.0, 40028.0, 64068.0], 'Pop': [18974.0, 11162.0, 14900.0, 22204.0, 5383.0, 19504.0]})
Pass the dataframes into Mito
To import the dataframe into Mito, just provide it as an argument to the mitosheet.sheet() function call.
# Render the Mitosheet with the data
mitosheet.sheet(train_stations, demographics)
Last updated
Was this helpful?