Bring your Pandas Dataframes to life with D-Tale

By Andrew Schonfeld

Tired of running

df.head()
on your dataframes? In this tutorial, we will explore the open-source visualizer for Pandas dataframes, D-Tale. Some of the features we'll touch on are installation, startup, navigating the grid, viewing column statistics, building a chart & code exports.

What is it?

D-Tale is the combination of a Flask back-end and a React front-end to bring you an easy way to view & analyze Pandas data structures. It integrates seamlessly with ipython notebooks & python/ipython terminals. Currently this tool supports such Pandas objects as DataFrame, Series, MultiIndex, DatetimeIndex & RangeIndex.

Step 1: Installation

Installation is available using pip or conda
            # conda
            conda install dtale -c conda-forge

            # pip
            pip install -U dtale
        
Source code is available here.

Step 2: Opening the Grid

Execute the following code within your Python console or jupyter notebook
            import pandas as pd
            import dtale

            df = pd.DataFrame(dict(a=[1,1,2,2,3,3], b=[1,2,3,4,5,6]))
            dtale.show(df)
        
You will be presented with one of the following: Examples
PyCharm jupyter

Step 3: Navigating the Grid

Once inside the grid you have all of the standard grid functionality at your fingertips by clicking column headers. If your still in the output cell of your jupyter notebook feel free to click the triangle in the upper lefthand corner to open the main menu and then click "Open in New Tab" to give you a larger workspace.

  • Sorting
  • Renaming
  • Filtering
  • Lock Columns to the Left side (this is handy if you have a very wide dataframe)

Step 4: Building Columns

If you open the main menu by clicking on the triangle in the upper lefthand corner you'll be presented with many options, one of which is "Build Columns". Click that and you see many options for different ways to build new columns based on your existing data. Here are some examples of a few of them:

Builder Main Menu Column Builder Menu Output
Transform (Groupby Mean)
Mean Adjust (Subtract Columns)
Winsorize

Step 5: View Column Statistics

Many times you'll want to be able to view a quick overview of the contents of your dataframe. One way to do this is by running

df.describe()
. We've brought that function to life with the "Describe" menu option. By either opening the main menu or clicking a column header and then clicking the "Describe" button (clicking from a column header will preselect that column for you).

If you take a look you'll notice a listing of different statistics (which will vary based on data type of the column selected). These statistics are the output of calling

df.describe()
on that column as well as some other helpful statistics like percentage of missings & kurtosis. You also have the ability to view other helpful information:

Step 6: Building a Chart With Your Data

By opening the main menu once more and clicking the "Charts" button you will be brought to a new tab with the ability to build the following charts using Plotly Dash:

Here's an example of building a bar chart comparing the raw values (a) to its grouped mean (b_mean). Now you'll also notice some links at the top of your chart:

Step 7: Code Export

Let's take a look at the output of clicking the "Code Export" link of you chart that we built in Step 6.

Now the goal of code export is to help users learn a little bit about what code was run to get them what their looking at, but it is by no means gospel. So feel free to submit suggestions or bugs on the Issues page page of the repo.


Here are some other competitors to D-Tale:

Thank you for reading this tutorial and I hope it helps you with your data exploration. There's many other features that I haven't touched on here so I urge you to check it out the README, particularly the different UI functions. If you liked this please support open-source and star the repo. :)