📈 Exploratory data visualization with chart blocks
Deepnote's new chart blocks supercharge your exploratory data visualization. Use this new block type to quickly uncover patterns in your data without having to write a single line of code. To learn how they work, we will extract key insights from two datasets—using nothing but chart blocks for visual exploration.
📘 There's a lot you can do with chart blocks. Read our docs to learn more.
Analysis
Which customers are most likely to churn?
The dataset below contains customer data from a telecommunications company. Some of these customers have churned and it's our job to understand why. Let's use chart blocks to see which factors relate to customer churn. Examine the table below to get a sense of the data.
👇 Is that an SQL block selecting from a CSV file? Yes it is!
Charting the relation between churn and tenure
Let's begin by looking at churn value as it relates to tenure. For this, we can make a histogram to represent tenure, and color its bars by the number of churned customers. Here are the steps to make this happen:
🔮 As you can see in the chart below, those with tenure less than 10 months are a bit more likely to churn.
We can see that tenure and churn are related, but what about the type of contract? Let's make a side-by-side bar chart that represents the number of churned customers versus the three contract types (i.e., monthly, one year, and two year). This is accomplished by following almost the exact same steps as we did with the histogram! Here's how you do it:
🔮 As you can see in the chart below, if a customer is going to churn, they are likely going to be on a month-to-month contract.
🤯 For extra points, we can even show this chart as stacked and normalized. This will help us understand the actual ratios across contract types for those who churned. Just change the stacking option in the bottom left of the chart block as shown below.
Turns out that, of those who churned, 89% were on a month-to-month contract (you can hover above the bars to see the tooltips).
Lastly, there are a few other columns of the data we haven't explored yet. Namely, dependents, partner, and seniorcitizen. These columns describe whether or not the customer has children, a partner, or is a senior citizen, respectively. We should examine the relationship between these variables and churn.
Since these columns only contain boolean values (true/false), we can chart them as layers on the same canvas. To accomplish this, do the following:
🔮 Interesting. Out of the ~1500 customers who churned, only 90 of them reported having dependents (0.06%). (Fun fact: did you know that the average of a boolean column is equal to the proportion of 1's?)
Analysis 2️⃣
How have global trends in economy and health changed over time?
The dataset below is the famous gapminder data. It contains data on global trends such as income and life expectancy, all couched within a coherent timeseries—making it a great resource for analysis. It's our job to explore this data to see what we can learn. Let's use chart blocks to see how life expectancy, GDP, and population size relate. Examine the table below to get a sense of the data.
Charting life expectancy over time for each continent
Let's begin by looking at how life expectancy has changed over time. Importantly, we will want to examine this for each continent. For this, we can make a multi-line chart where each line represents a continent's change over time. Here are the steps to make this happen:
🔮 As you can see in the chart below, life expectancy has steadily increased, but it is still much higher for some countries/continents compared to others.
Charting median GDP over time for each continent (and adding a global comparison)
Before looking at how life expectancy relates to economic health (as measured by GDP), let's look at GDP for each continent over time. Since there are multiple rows for each continent, we can aggregate GDP to get a simple chart to begin with. Let's also add a global aggregation as a benchmark. The best way to represent these features will be to use a scatter and line chart together (as a layered chart). Here are the steps:
🔮 As you can see in the chart below, GDP (a proxy for economic health) has increased rapidly for Oceania (New Zealand and Australia) and Europe.
🧸 As a bonus, you may notice that I also set the Size option. By setting it to AVG and pop (for average population size), the circles now represent population size.
Charting life expectancy and GDP
Do personal health and and economic health go hand in hand? Well, we can check this with our proxies for those concepts—life expectancy and GDP, respectively. A simple scatter plot should do the trick; however, as you will see, the range of the GDP is so wide that we will need to use a logarithmic scale in order to properly visualize the data. Thankfully, chart blocks can handle that. Here's how we can set things up:
🔮 By these measures, personal health and and economic health do go hand in hand. People tend to live longer in richer countries (or, countries are richer where people tend to live longer).
💅 As you can see, I've also formatted this chart in various ways (axis labels, title, range) and I've hidden the UI for "pretty". Check out the "format" and "display" tabs for more.
Believe it or not, that's all there is to it.
Did you notice that there were only 2 lines of code in this notebook—and neither of them were for building charts? And yet, look at the rich exploratory visualization that we accomplished. You can expect even more functionality in the coming weeks. Enjoy Deepnote's brand new chart blocks (we enjoyed developing them).