Low Code DataFrame Formatting in Python

Jake from Mito
3 min readDec 12, 2022

--

You can format a DataFrame in python using pandas code — it is not an intuitive or speedy undertaking. Python is amazing for so many things — formatting is not one of them.

Here is the full pandas documentation for formatting and styling of DataFrames.

For example, in the screenshot below, you can an example of the formatting available and code required to achieve it.

https://pandas.pydata.org/docs/user_guide/style.html

  1. This doesn’t look great
  2. That code looks annoying to write (even if you are fabulous at Python)

Mito has a way to format DFs much faster and generated clean code for you — no need to write any code yourself.

Mito is an open source Python package that allows the user to edit DataFrames as if they are spreadsheet. Each edit you make generates the equivalent Python for you.

You can filter, pivot, graph, sort, use formulas etc. and all the Python syntax will appear in the code cell below.

You can install Mito with these two commands

python -m pip install mitoinstaller
python -m mitoinstaller install

Here are the full install instructions

Below you can see that you can pass any DataFrame, CSV or Excel file into Mito and format it using a visual editor — inside your notebook!

The Mito formatting menu will auto suggest formatting styles that you can use. All you need to do is click an icon and the formatting will be applied and the equivalent code will be written for you.

Here is the code that is written for you:

No matter your skill level at Python, this is code that will certainly take time and require you to look at some form of documentation. Mito eliminates that.

You can also select your formatting more specifically, beyond the autogenerated styles:

If you print the DataFrame, you can see the formatted DF outside of the mitosheet:

This is one of the common ways that people using Mito — bring their data into Mito for something like formatting, graphing, or pivot tables, and then carry on with their analysis using the generated code and DataFrames.

Another style of formatting available is column formatting:

A user can change their column to accounting style, percentage, scientific notation etc. — and generate the code as well.

All these formatted DFs can be exported to Excel/CSV as well.

Definitely check out Mito, next time you want to format something in Python.

Here is the website!

--

--

Jake from Mito
Jake from Mito

Written by Jake from Mito

Exploring the future of Python and Spreadsheets

Responses (1)