{"id":391,"date":"2020-08-13T17:23:51","date_gmt":"2020-08-13T17:23:51","guid":{"rendered":"https:\/\/data-science.gotoauthority.com\/2020\/08\/13\/bring-your-pandas-dataframes-to-life-with-d-tale\/"},"modified":"2020-08-13T17:23:51","modified_gmt":"2020-08-13T17:23:51","slug":"bring-your-pandas-dataframes-to-life-with-d-tale","status":"publish","type":"post","link":"https:\/\/wealthrevelation.com\/data-science\/2020\/08\/13\/bring-your-pandas-dataframes-to-life-with-d-tale\/","title":{"rendered":"Bring your Pandas Dataframes to life with D-Tale"},"content":{"rendered":"<div id=\"post-\">\n<p><b>By <a href=\"https:\/\/www.linkedin.com\/in\/andrew-schonfeld-b6113233\/\" target=\"_blank\" rel=\"noopener noreferrer\">Andrew Schonfeld<\/a>, Full-stack Developer &amp; Creator of <a href=\"https:\/\/github.com\/man-group\/dtale\" rel=\"noopener noreferrer\" target=\"_blank\">D-Tale<\/a><\/b><\/p>\n<p><a href=\"https:\/\/github.com\/man-group\/dtale\" rel=\"noopener noreferrer\" target=\"_blank\"><br \/><img alt=\"\" class=\"aligncenter\" src=\"https:\/\/raw.githubusercontent.com\/aschonfeld\/dtale-media\/master\/images\/Title.png\" width=\"100%\"><br \/><\/a><\/p>\n<p>Tired of running <code>df.head()<\/code> on your dataframes? In this tutorial, we will explore the open-source visualizer for Pandas dataframes, D-Tale. Some of the features we&#8217;ll touch on are installation, startup, navigating the grid, viewing column statistics, building a chart &amp; code exports.<\/p>\n<p>\u00a0<\/p>\n<h3>What is it?<\/h3>\n<p>\u00a0<br \/>D-Tale is the combination of a Flask back-end and a React front-end to bring you an easy way to view &amp; analyze Pandas data structures. It integrates seamlessly with ipython notebooks &amp; python\/ipython terminals. Currently this tool supports such Pandas objects as DataFrame, Series, MultiIndex, DatetimeIndex &amp; RangeIndex.<\/p>\n<p>\u00a0<\/p>\n<h3>Step 1: Installation<\/h3>\n<p>\u00a0<br \/>Installation is available using pip or conda<\/p>\n<div>\n<pre><code>\r\n# conda\r\nconda install dtale -c conda-forge\r\n\r\n# pip\r\npip install -U dtale<\/code><\/pre>\n<\/div>\n<p>Source code is available <a href=\"https:\/\/github.com\/man-group\/dtale\" rel=\"noopener noreferrer\" target=\"_blank\">here.<\/a><\/p>\n<p>\u00a0<\/p>\n<h3>Step 2: Opening the Grid<\/h3>\n<p>\u00a0<br \/>Execute the following code within your Python console or jupyter notebook<\/p>\n<div>\n<pre><code>\r\nimport pandas as pd\r\nimport dtale\r\n\r\ndf = pd.DataFrame(dict(a=[1,1,2,2,3,3], b=[1,2,3,4,5,6]))\r\ndtale.show(df)<\/code><\/pre>\n<\/div>\n<p>You will be presented with one of the following:<\/p>\n<ul>\n<li>Python console: A link which depending on your terminal settings you can either click or copy into a browser which will bring you to the D-Tale grid.\n<\/li>\n<li>jupyter notebook: An output cell containing the D-Tale grid\n<\/li>\n<\/ul>\n<p><b>Examples<\/b><\/p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">PyCharm<\/th>\n<th align=\"center\">jupyter<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\"><a href=\"https:\/\/raw.githubusercontent.com\/aschonfeld\/dtale-media\/master\/gifs\/dtale_demo_mini.gif\" rel=\"noopener noreferrer\" target=\"_blank\"><img alt=\"\" class=\"aligncenter\" src=\"https:\/\/raw.githubusercontent.com\/aschonfeld\/dtale-media\/master\/gifs\/dtale_demo_mini.gif\" width=\"100%\"><\/a><\/td>\n<td align=\"center\"><a href=\"https:\/\/raw.githubusercontent.com\/aschonfeld\/dtale-media\/master\/gifs\/dtale_ipython.gif\" rel=\"noopener noreferrer\" target=\"_blank\"><img alt=\"\" class=\"aligncenter\" src=\"https:\/\/raw.githubusercontent.com\/aschonfeld\/dtale-media\/master\/gifs\/dtale_ipython.gif\" width=\"100%\"><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u00a0<\/p>\n<h3>Step 3: Navigating the Grid<\/h3>\n<p>\u00a0<br \/>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 &#8220;Open in New Tab&#8221; to give you a larger workspace.<\/p>\n<table>\n<tr>\n<td>\n<ul>\n<li>Sorting\n<\/li>\n<li>Renaming\n<\/li>\n<li>Filtering\n<\/li>\n<li>Lock Columns to the Left side (this is handy if you have a very wide dataframe)\n<\/li>\n<\/ul>\n<\/td>\n<td>\n<img alt=\"\" class=\"aligncenter\" src=\"https:\/\/raw.githubusercontent.com\/aschonfeld\/dtale-media\/master\/images\/kdnuggets\/Column_menu.png\" width=\"100%\">\n<\/td>\n<\/tr>\n<\/table>\n<p>\u00a0<\/p>\n<h3>Step 4: Building Columns<\/h3>\n<p>\u00a0<br \/>If you open the main menu by clicking on the triangle in the upper lefthand corner you&#8217;ll be presented with many options, one of which is &#8220;Build Columns&#8221;. 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:<\/p>\n<p>\u00a0<\/p>\n<h3>Step 5: View Column Statistics<\/h3>\n<p>\u00a0<br \/>Many times you&#8217;ll want to be able to view a quick overview of the contents of your dataframe. One way to do this is by running <code>df.describe()<\/code>. We&#8217;ve brought that function to life with the &#8220;Describe&#8221; menu option. By either opening the main menu or clicking a column header and then clicking the &#8220;Describe&#8221; button (clicking from a column header will preselect that column for you).<\/p>\n<p><img alt=\"\" class=\"aligncenter\" src=\"https:\/\/raw.githubusercontent.com\/aschonfeld\/dtale-media\/master\/images\/kdnuggets\/Describe.png\" width=\"100%\"><\/p>\n<p>If you take a look you&#8217;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 <code>df.describe()<\/code> on that column as well as some other helpful statistics like percentage of missings &amp; kurtosis. You also have the ability to view other helpful information:<\/p>\n<ul>\n<li>Boxplot of min, q1, median, mean, q3, max\n<\/li>\n<li>Histogram of column values\n<\/li>\n<li>Value counts of unique values\n<\/li>\n<li>Toggle visibility of columns using the grid on the left\n<\/li>\n<\/ul>\n<p>\u00a0<\/p>\n<h3>Step 6: Building a Chart With Your Data<\/h3>\n<p>\u00a0<br \/>By opening the main menu once more and clicking the &#8220;Charts&#8221; button you will be brought to a new tab with the ability to build the following charts using Plotly Dash:<\/p>\n<ul>\n<li>Line\n<\/li>\n<li>Bar\n<\/li>\n<li>Scatter\n<\/li>\n<li>Pie\n<\/li>\n<li>Wordcloud (this is a custom plugin specific to D-Tale so some features like exporting may not work)\n<\/li>\n<li>Heatmap\n<\/li>\n<li>3D Scatter\n<\/li>\n<li>Surface\n<\/li>\n<li>Maps (Choropleth, Scattergeo &amp; Mapbox)\n<\/li>\n<\/ul>\n<p>Here&#8217;s an example of building a bar chart comparing the raw values (a) to its grouped mean (b_mean).<\/p>\n<p><img alt=\"\" class=\"aligncenter\" src=\"https:\/\/raw.githubusercontent.com\/aschonfeld\/dtale-media\/master\/images\/kdnuggets\/Bar_chart.png\" width=\"100%\"><\/p>\n<p>Now you&#8217;ll also notice some links at the top of your chart:<\/p>\n<ul>\n<li>Popup Chart: Open your chart in a new tab so you can build another and compare.\n<\/li>\n<li>Copy Link: Copy a link to your chart into your clipboard to show someone else.\n<\/li>\n<li>Export Chart: Export your chart to a static HTML and send it as an attachment in e-mails.\n<\/li>\n<li>Export CSV: Export the underlying data of your chart to CSV.\n<\/li>\n<li>Code Export: Export the underlying code that built your chart so you can make any customizations or just learn how it was built.\n<\/li>\n<\/ul>\n<p>\u00a0<\/p>\n<h3>Step 7: Code Export<\/h3>\n<p>\u00a0<br \/>Let&#8217;s take a look at the output of clicking the &#8220;Code Export&#8221; link of you chart that we built in Step 6.<\/p>\n<p><img alt=\"\" class=\"aligncenter\" src=\"https:\/\/raw.githubusercontent.com\/aschonfeld\/dtale-media\/master\/images\/kdnuggets\/Code_export.png\" width=\"100%\"><\/p>\n<p>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 <a href=\"https:\/\/github.com\/man-group\/dtale\/issues\" rel=\"noopener noreferrer\" target=\"_blank\">Issues page<\/a> page of the repo.<\/p>\n<p>Here are some other competitors to D-Tale:<\/p>\n<p>Thank you for reading this tutorial and I hope it helps you with your data exploration. There&#8217;s many other features that I haven&#8217;t touched on here so I urge you to check it out the <a href=\"https:\/\/github.com\/man-group\/dtale#contents\" rel=\"noopener noreferrer\" target=\"_blank\">README<\/a>, particularly the different UI functions. If you liked this please support open-source and star the <a href=\"https:\/\/github.com\/man-group\/dtale\" rel=\"noopener noreferrer\" target=\"_blank\">repo<\/a>. \ud83d\ude42<\/p>\n<p>\u00a0<br \/><b>Bio: <a href=\"https:\/\/www.linkedin.com\/in\/andrew-schonfeld-b6113233\/\" target=\"_blank\" rel=\"noopener noreferrer\">Andrew Schonfeld<\/a><\/b> has been a full-stack developer for about 14+ years. Up until about 3 months ago he had spent his entire career located in Boston where he grew up working in finance. Working with a team of data scientists and being completely immersed in Python he was able to start building a suite of tools using Flask, Pandas &amp; React on the front-end.  Eventually, the problem of finding a way to visualize Pandas dataframes came along and the result was D-Tale. Along with the support of his company at the time he was able to open-source this software and it eventually gained a lot of traction with the data science community. He has spent the last 15 months working on D-Tale (mostly in my spare time since switching jobs) giving presentations at Boston &amp; San Diego Python user groups as well as FlaskCon this past July.<\/p>\n<p><b>Related:<\/b><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/www.kdnuggets.com\/2020\/08\/bring-pandas-dataframes-life-d-tale.html<\/p>\n","protected":false},"author":0,"featured_media":392,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/posts\/391"}],"collection":[{"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/comments?post=391"}],"version-history":[{"count":0,"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/posts\/391\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/media\/392"}],"wp:attachment":[{"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/media?parent=391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/categories?post=391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/tags?post=391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}