Python for Data-Driven Storytelling

by Barbara Coelho | May 01, 2020 | 0 Comments

Marketers? Common. Engineers? Common. But a marketer and engineer in one? Now that’s a rare breed. Our CEO, Hamlet Batista, gave a captivating presentation at the Inbound Conference where he shared the impact that Python can have for data-driven storytelling and how it can create compelling content to make you stand out among competitors. The steps include: sourcing ideas, extracting, processing, and visualizing data, and then reframing it to create powerful, mesmerizing stories for your audience. 

Watch Hamlet’s presentation:

View Hamlet’s presentation deck:

Python for Data-driven Storytelling from Hamlet Batista

 

  1. Sourcing Ideas: Where do we look for ideas?

Hamlet gets his idea from a previous trip he took with his family to Disney World. The parks are great, fun, and exciting for all, but the downside of course is the time lost waiting in those long lines. He used a subreddit called “Data is Beautiful” to find data comparing ride enjoyment to line wait times. He plans to take this data and recreate it into a visualization that will have meaning and provide a more significant impact.

Why reframe popular stories?

Although big data proves to be useful, it lacks an emotional connection to hook the audience. Marketers and engineers appear to operate in silos—with the engineer’s focus on logic and removing all context from the data. The marketer’s job is to personalize and add back all the context to understand the target audience and provide an emotional connection. Here’s a powerful example of how Disney references the people who visit their parks to create an intimate relationship:

2. Extracting Data: Pulling data that matters

The first step in this phase is to extract the ride durations by first using Google Chrome to get an HTML DOM element selector with these ride times.

 

Next, use requests-html to extract the JavaScript snippets from the source page.

Up next, use regular expressions to extract the duration numbers.

Now we will extract the average wait times by again using requests-html to extract JavaScript snippets from the moving charts. Since the data is moving in real-time, it’s a challenging task to grab the pieces, a process Hamlet compares to catching a cab in New York City, something that will, without a doubt, test your patience, but is doable. 

Next, we can use regular expressions to extract the data rows from the JavaScript and use a Jinja2 template to return the data needed for the visualization.

3. Processing Source Data: How do we process data to gain valuable insights?

First, we will split our data into two Python dictionaries using duration per ride and ride names. 

Then, we will filter the rides to account for those with minimal or excessive data.

Next, we will determine the average wait time for each ride and combine it with ride duration into one data frame. Finally, we will eliminate the empty columns at the end.

4. Visualizing Data: How do we tell a story?

This is where the power comes from—with this raw data, we can manipulate it to provide more relevant, rich visualizations for our target audience. This step is much easier: we will reformat the data frame to fit a row-oriented dictionary. 

5. Reframing Visualization: How do we connect with our customer with a compelling visual?

Here, we will add another data point, which will tell us how fun each ride was based on the age group. We will retrieve this data from https://touringplans.com/disneyland/attractions and then calculate the “enjoyment score,” the number of minutes per ride divided by the average minutes of wait time, and use plotly to display a bar chart featuring the results.

Here we have created the final visualization that not only provides valuable information but is more engaging and meaningful to our audience.

Reframing successful visualizations

The key to every successful visualization is creating an emotional connection. Who is your target audience? What is their biggest fear? Asking yourself these two questions can help you get a sense of what they’re looking for. In the travel industry, this may look like adults, families, or business people and extensive wait times at security. In recruitment, it can look like job seekers and regions with poor job growth. In real estate, it can look like house hunters and noisy cities. 

How to ask reframing questions: Using the information refinement framework

You can take these popular visualizations and adapt them to your business by turning raw data into insights. The information refinement framework enables you to recognize trends and patterns and act on the knowledge it gives you to direct your content. The DIKW pyramid is split up into four levels starting from the bottom with data, information, knowledge, and wisdom as the point. It provides a systematic, organized way to reframe this idea and adapt this to your business. At each step, you can see which types of questions you should be asking yourself, and the answers you come up with will help set your business in the right direction. 

Start with possible outcomes

Creativity is not always linear—you don’t necessarily need to start with data and finish with insights. Sometimes, you start where you’re most comfortable, as Jeff Bezos says, “Start with your customer and work backwards.”

Why tell data stories?

When it comes to standing out, it may be challenging to grow your content and have people read, watch, and pay attention to it. The concept of “riding existing demand waves” taps into preexisting demand and desire for a product and allows you to channel it by telling unique, relatable stories.

Entrepreneurs, for example, follow this concept by tapping into an existing need and creating an emotional connection to be successful. The two most important things to focus on when determining how to build this emotional connection is narrowing your target customer and presenting a message that will move them. This is essential since different emotions appeal to different groups of customers. One company that achieved significant success in establishing an emotional connection with its customers was Huggies. They conducted a study which found that hugging your baby resulted in health benefits for children, and then used this data to their advantage through education marketing, which increased their engagement rate by 300% and their sales by 33%. Below are additional examples.

The power is in your hands—turn your hard data into a powerful, compelling story to build emotional connections with your audience that will help you stand out among your competitors and succeed.

New to coding? Try out Codecademy and Kaggle to start learning the basics!

Barbara Coelho

Social Media Manager

0

REPLIES

Comments are closed.

Install our free SEO monitoring app today

RankSense can detect traffic-killing SEO issues in real time, and send instant notifications to your e-mail, phone or Slack channel. You have full control of the type of alerts you receive by severity and the frequency of alerts.

OUR BLOG

Latest news and tactics

What do you do when you’re losing organic traffic and you don’t know why?

Our Uphill Journey to Product Market Fit & Tips to Get There

The following blog post includes an interview with Hamlet Batista and Cloudflare’s Zach Bloom. What the full interview on CloudflareTV here. Bloom: I would love to hear about the story of RankSense and what problem it solves. Batista: Ranksense is an agile SEO platform. It’s about doing things iteratively, having a fast feedback loop, and...

READ POST

Working Remotely: The Pros, the Cons, and How to Succeed

In this interview with Aleyda Solis, Hamlet goes into the ins and outs of working remotely, why he chose this for RankSense, and why it works so well. Watch the full interview on Remoters.  RankSense is a fully remote business consisting of employees from all across the globe, including India, Europe, and the United States to...

READ POST