Welcome to Mito! This guide will show you how get your Python analyses done 10x faster, all within a familiar spreadsheet interface.
In this tutorial, we'll walk you through your first analysis using Mito! We'll look for a connection between the number of Airports that allow pets and average household income in each U.S. state.
During this analysis, we'll see how to write formulas, merge data sets, and create pivot tables - and Mito will generate the equivalent Python for every edit we make!
Launch your JupyterLab and create a blank notebook.
Download the example data below.
Drag and drop the data into your Jupyter file system. You can see a short video of how to do so here.
Copy and paste the following two lines of code into the first cell of your Jupyter notebook
Press Shift + Enter to run the code you just copied and pasted.
Great! Now that you've created a Mitosheet, let's add our data.
Click the Import button
Select Airport-Pets.csv and Zipcode-Data.csv.
To understand the relationship between these datasets, we need to combine them together.
To combine the datasets, we'll use Mito's Merge functionality. Merge looks for matches between the key column of the first sheet and a key column of the second sheet, and then combines those matches into a single row.
Click the Merge button in the Mito toolbar.
Make sure that the Merge Key for both sheets is Zip.
Click the X button in the top right hand corner of the Merge taskpane because we want to keep all of the columns in our merged datasets.
Notice that a new sheet, df3, was created. Let's rename it to something more informative.
Click on the gray downward facing arrow in the df3 sheet tab at the bottom of the Mito Sheet.
Click rename and name the sheet Data.
Have you noticed the code that Mito generated below the Mito Sheet? For each edit that we made in Mito, we've generated the equivalent code - writing Python has never been so easy!
Now that we've organized our data, we can move forward just like we were in Excel.
We're going to use a pivot table to compare states, but first let's convert the Pets column into a format we can work with.
Click on the Data sheet tab.
Click on the Add Column button and notice the new column that was generated to the right of the selected column.
Click on the column header of the newly created column to give it a better name.
In the taskpane that appears, name the column Allowed_Pets and press Enter to submit.
Close the taskpane by clicking the X button.
Now that we've got our new column setup, let's write a formula.
Using your mouse, select the first cell in the Allowed_Pets column and press Enter to start writing a formula.
Write the formula, =IF(Pets == 'Y', 1, 0) which sets the column to 1 if the Pets column has a Y in it, and 0 otherwise.
Press Enter again to set your formula!
Pivoting allows us to slice and dice our data however we want, creating powerful analyses in seconds.
Click on the Data sheet tab
Click on the Pivot button in the toolbar
In the Rows section, select the State column, telling Mito to create one row for each state.
In the Values section, select the Allowed_Pets column.
Click on the count button and select the sum aggregation method.
In the Values section, click on the add button again and select the Median_Income column.
Switch the aggregation method from count to mean
Now that our data is grouped, let's sort it to look for a relationship between allowed pets and average state income.
Make sure you selected the Mito Sheet tab df4
Click on the filter icon in the Median_Income column header to open the column control panel.
Click the Descending button, and notice that the data is now sorted in descending order.
Click the X button to close the taskpane.
As we've noted a few times throughout this tutorial, each time we made an edit to Mito, the equivalent production-ready Python code is generated right below the Mito Sheet!
To interact with the generated code:
Select the Mito generated code cell. It's right below the Mito sheet, and should start with
# MITO CODE START (DO NOT EDIT).
Press Shift+Enter to run the cell.
Now that we've ran the Mito generated code, we can use the updated dataframes throughout the rest of this notebook. Try it out by running the following code in a new code cell.
We've used Mito to do our analysis, and got the corresponding Python code for free. Mito is the quickest way to get your Python data analytics done.
You're ready to start writing Python code 10x faster! Now its time to try it on your own data.