Mito
Search…
Pass a dataframe into Mito
You can 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.
1
# Import Python packages
2
import mitosheet
3
import pandas as pd
Copied!

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.
1
# Create some simple data to display
2
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']})
3
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]})
Copied!

Pass the dataframes into Mito

To import the dataframe into Mito, just provide it as an argument to the mitosheet.sheet() function call.
1
# Render the Mitosheet with the data
2
mitosheet.sheet(train_stations, demographics)
Copied!
Copy link
Contents