How to Analyze Data Using Mito in Python | Towards Data Science

Data contains so many meaningful insights. Data Analysis is the way for getting those insights. Sometimes, we get confused about choosing which tools we want to use, whether using spreadsheet software like Excel. Or we can use a programming language like Python.
And for some people, they prefer to use the spreadsheet tool. One of the reasons for that is because they cannot do programming yet.
Using the spreadsheet tool is not recommended for big data. Therefore, we need programming for analyzing big data. But thankfully, there’s a tool for connecting both. It’s called Mito.
Mito is a library that has capabilities for analyzing the data. Unlike the Pandas library, Mito has an interface like the spreadsheet software. Therefore, we can explore and process the data without interfering with codes.
In this article, I will show you how to analyze data using Mito. Also, I will show you the features that are included in this tool. Without further, let’s get started!
Before we can use the library, we need to install it first. We need to install the mitoinstaller library for installing Mito with the ‘pip’ command. Here is the command for doing that:
python -m pip install mitoinstaller
After that, you can install Mito by using this command line:
python -m mitoinstaller install
If your installation is complete, it will show texts like this:
Now we can load the library on the notebook.
Keep in mind that you can use Mito only with JupyterLab. Until now, you cannot access it using the regular Jupyter Notebook.
Now let’s initialize the Mito sheet. For doing that, please copy these lines of code:
import mitosheetmitosheet.sheet()
Here is the result for running the code:
If you can see the interface on the notebook, it means that you can use it now.
For the data source, we will use a dataset from Kaggle called Top Streamers on Twitch. Basically, the dataset contains information about the top 1000 streamers from 2020.
The information that is included on the dataset is the number of viewers, followers, language name, channel name, etc. You can access the dataset here.
Disclaimer:The dataset is in the public domain. It also contains the ‘CC0: Public Domain’ License. For more details, you can take a look here.
To open the dataset, we need to create a dataframe object from it. We can use the pandas library for doing that. Let’s write these lines of code for doing that:
import pandas as pddf = pd.read_csv('twitchdata-update.csv')
After we get the dataframe, the next step is to load it into our Mito sheet. Add this line of code for doing that:
mitosheet.sheet(df)
Here is the result for running the code:
As you can see from above, the data is already loaded. Now let’s explore what Mito can do.
With Mito, we can explore and customize the dataset like on a spreadsheet. The first feature that I want to show you is to add a column to the dataset.
Let’s say we want to add a column where it has a boolean value that determines whether the channel is in the English language or not. We called the column the ‘is_english’ column.
For adding the column, have a look at this GIF:
Because Mito is like a spreadsheet tool that we can use in our notebook, we can use formulas like the spreadsheet software for customizing columns.
Let’s recall the is_english column. We want to set boolean values to 1 if the language is English. In spreadsheet software, we can use a formula like this:
IF(language == 'English', 1, 0)
Let’s apply the formula on Mito. Here is the GIF for the process:
After we set the column’s values, let’s filter the data based on the ‘is_english’ column. We will take rows that contain the value of 1.
In Mito, we can do that easily. We only need to give parameters for doing the filtering process. Have a look at this GIF:
The next feature that we can do is to visualize the data. With Mito, we can display charts easier rather than spending time writing codes and looking at the helper’s website for getting syntax for certain problems. We can visualize charts like box plot, histogram, scatter plot, and bar plot.
The next feature that I want to show you is to create the pivot table. Just like previous features, we only need to give parameters for doing a certain task.
For creating the pivot table, we can set which column is acts as the row, the column, and the value. From that table, we can see the value based on specific columns. In this case, we want to aggregate the number of followers based on maturity and language.
Please have a look at this GIF for how to create the pivot table:
Let’s have a look at our pivot table. As you can see, the table contains the number of followers based on maturity and the language. But we still didn’t get the insights. Let’s sort the data first.
With Mito, sorting the data is simple. We only have to click several buttons for doing that. Please have a look at this GIF:
If we sort the column that has no mature content, we can see that English is the most language. And then it follows by Korean, Russian, Spanish, and so on.
But if you see more details, the number of followers for non-mature content is not the same as the mature one. Let’s sort the data on the mature column. Here is the result for doing that:
As you can see, the Korean is not in second place. Most of them are European languages. And Korean language is below Chinese and Thai.
Here is the last thing that Mito can do. It generates codes. When we conduct some processing on the data, it automatically generates codes based on it. In my case, here is the code that has been generated by Mito:
As you can see, it looks like the pandas command that we’ve used. With Mito, we can do the process like the spreadsheet software and generate code based on it.
Well done! Now you have learned how to analyze data using Mito in Python. For those who are new to programming and data analysis, I hope it helps you for getting started.
If you are interested in this article, please follow my Medium for more articles like this. I will talk about lots of data science ranging from tutorials to applications on many domains.
If you have any questions or want to discuss, you can contact me on LinkedIn or E-Mail (khaliddotdev@gmail.com).
Thank you for reading my article!