Home Artificial Intelligence Grow a Treemap with Python and Plotly Express

Grow a Treemap with Python and Plotly Express

0
Grow a Treemap with Python and Plotly Express

Turn a government PDF right into a financial planning tool

A photo looking up the trunk of a tree in autumn.
Photo by Robert Murray on Unsplash!

Hierarchical data is an information model where items are linked to one another in parent-child relationships, forming a tree structure. Some obvious examples are family trees and company organization charts.

A treemap is a diagram that represents hierarchical data using nested rectangles. The world of every rectangle corresponds to its numerical value. Treemaps have been around for about 30 years. An early application was to visualise harddisk usage, as demonstrated within the figure below.

A treemap of nested rectangles in yellows and oranges.
Allocation of hard disk space visualized with a treemap (Carnivore1973 via Wikimedia Commons)

Treemaps allow you to capture each the value of individual categories and the structure of the hierarchy. They’re useful for:

  • Displaying hierarchical data when the variety of categories overwhelms a bar chart.
  • Highlighting proportions between individual categories and the entire.
  • Distinguishing categories using different sizes and colours.
  • Spotting patterns, primary contributors, and outliers.
  • Bringing a fresh look to data visualization.

On this Quick Success Data Science project, we’ll use Python to create a treemap to assist people budget for expenses. We’ll first use the tabula-py library to show a web-based Bureau of Labor Statistics PDF right into a pandas DataFrame. Then we’ll use the Plotly Express library to show the DataFrame into a beautiful and interactive area-based visualization.

With the pandemic and subsequent inflationary surge, consumer spending has drawn a variety of attention. Individuals have to know tips on how to budget effectively, and policymakers need to grasp what sectors are causing probably the most financial burden to potential voters.

To assist track income and spending, the Census Bureau uses Consumer Expenditure Surveys to gather information on US consumers’ expenditures, income, and demographic characteristics. The Bureau of Labor Statistics (BLS) then compiles these statistics into annual

LEAVE A REPLY

Please enter your comment!
Please enter your name here