Data Exploration with the dtale Library in Python

Kavish Last Updated : 02 Dec, 2020
6 min read

This article was published as a part of the Data Science Blogathon.

Introduction

Data Analysis is the most essential part of any data science project. Analyzing the data gives us some important and beautiful insights about the data. There are many libraries in Python to perform analysis like Pandas, Matplotlib, Seaborn, etc.

Recently developers introduced a new library ‘dtale’ to perform analysis with fewer lines of code.

dtale

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

Let’s dive in and see how to work with this dtale library in Python!

 

Setting up the Environment for dtale

conda create -n dtale python
conda activate dtale

Now we first need to install the dtale library in the respective environment.

pip install dtale

 

Exploratory Data Analysis with dtale

Now let’s dive into our data with dtale.

import dtale   ## importing D-Tale library

Importing Seaborn will help us to load data sets. Seaborn has many default Data sets. We will be using the ‘planets’ data set for the below analysis.

import seaborn as sns
df=sns.load_dataset(‘planets’)
dtale.show(df, ignore_duplicate=True)

After running the above code, the user can access below interactive table to perform multiple actions and visualize the dataset.

import dtale

  D-tale interactive table shows the number of columns and rows of the dataset at the top left corner (in this case, 1035 rows and 6 columns)

D-Tale shows us the data in the same way that pandas would. The only difference is the menu in the top left corner that allows us to do many things with the data.

Clicking on any of the column headings opens a drop-down menu that gives us options to sort the data and display it exactly as we want it.

column method dtale

 

The menu has many options. Let’s explore each one by one.

Describe option:

The most interesting options we can find in this menu are Describe that shows us a statistical analysis of the selected column and Column Analysis that shows us a histogram of the selected column.

Describe Option

                                                      Describe Option

After selecting the required column we will be able to see three major options Describe, Histogram, and Categories options in the middle of the screen. The describe option gives us statistical information about selected column data and Histogram gives the corresponding graphical representation. The third option is Categories In that, we will be able to select the X-axis variable from the Category Breakd.

Distance

                                                                          Categories

Another important and awesome feature of this Library is the ‘Code Export’ option at the top right corner. This feature provides the code for a particular output. also, In the Describe menu, we will be able to see all the outliers and Uniques values at the bottom.

python code

                                                                            Python code

Dimensions/Main Menu:

In the D-Tale main menu, you will find all the options available in D-Tale. This is where all the magic of D-Tale is. By clicking the highlighted play button at the top left corner of DataFrame you will be able to view all Options as shown in the below image.

dimensions dtale

                                                                            Main menu

D-Tale provides the ability to perform simple operations such as sorting, filtering, and formatting.

The Duplicates option is the main will help us to remove duplicate values in the Data set and the Custom Filter option has the ability to apply filters to columns. The most important Options used for data visualization are Correlations, Charts, and Heatmaps.

 

Correlations:

Once you click on the Correlations option in the Main menu, it will redirect you to another Correlation Tab. In this, we have to Choose variables in the ‘View correlation for’ dropdown. After selecting values in Dropdown if you click on the Correlation value, you will be able to see a visual representation of the Correlation between two variables in the Scatter plot as shown in the below image.

correlation

                                                                                Correlation

Charts:Charts Option in the Main menu helps us to visualize all different kinds of charts (Line, Bars, ScatterPlot, Circular, Wordcloud, Heatmap, 3D ScatterPlot, and Surface). One of the fantastic features of D-Tale is Interactive plots, it also supports 3d Charts and animations with the group by and aggregation functions also. It is really useful as you can visualize any type of relationship using different charts. The below images show a few examples of charts that we can generate using the Chart option in D-Tale.

charts
                                                                                Scatter plot
word cloud
                                                                                 WordCloud

Finally, one of the fanciest options is Heatmap. It shows the colors in the data table according to the value of each cell. the export CSV option in can b used for exporting the graphical data into a CSV file

heatmap
                                                                         Heatmap

Conclusion

In this paper, we saw how D-tale can save our time and efforts to create visually appealing and insightful EDA reports. This EDA Reporting tool is highly useful in analyzing and visualizing all types of datasets. D-Tale is one of the popular libraries in the Data Science community. There are a lot of options are available in D-Tale which helps us to understand the trend of Data from a statistical perspective, Hence keep exploring.

 

Reference

https://pypi.org/project/dtale/

I am a freelance Data Science professional with immense passion to solve Data driven problem. I have almost one year of industry experience. I love to write, explore new use cases of data science, and travel. I am open to a collaboration to learn, teach and grow more.

Responses From Readers

Clear

Abhishek Acharya
Abhishek Acharya

Very helpful article thanks to the author...

We use cookies essential for this site to function well. Please click to help us improve its usefulness with additional cookies. Learn about our use of cookies in our Privacy Policy & Cookies Policy.

Show details