The world’s leading publication for data science, AI, and ML professionals.

Restaurants Re Openings

A visual way to track of how is the business recovering

Photo by Gabriella Clare Marino on Unsplash
Photo by Gabriella Clare Marino on Unsplash

Many industries in the world have been slowly normalizing their activities due to the pandemic in recent months and the restaurant sector is no exception. Currently, there are sites where data can be collected that better explain how the sector has been recovering.

This article deals with the key points of how to create your own dataset and through visualization find the reasons for its slow economic recovery.

About the Data

  1. Opentable: The dataset shows the year-over-year seated diners at a sample of restaurants on the OpenTable network across all channels: online reservations, phone reservations, and walk-ins. The company compares the same day of the week from the same week in the previous year. For example, if there were 50 seated covers in restaurants that have recently reopened in a given locale on Tuesday of week 11, 2019, and on the same day in 2020 there was 1, then an opening rate of 2% will be displayed. A 0% opening rate means seated dining is the same as last year and a -100% means everything is shut down.
  2. Holidays: To give you a better explanation of what is behind the trends or peaks in the data, I have compiled the holidays of the countries that belong to the Opentable network and then put them together.

Building the Dataset

Before doing the visuals you need to prepare the data. The details of its preparation will not be explained (more details on references), but the key concepts that lead us to the dataset that serves as a source for the visualization that you want to reach will be explained. First, both datasets look like a pivot format, so you must convert them to a table or transactional format. Second, additional variables are necessary to allow us to manipulate the displays to see what is hidden.

Transforming Datasets

Here is an illustration of this conversion.

Image by Carlos León
Image by Carlos León

Here are the code snippets of the key points

Creating New Variables

Conversion of the table format is not enough. That is why we need some variables calculated from data to manipulated our visualizations:

  • isDateAfterMarch: a boolean variable to filter dates and see the pandemic effect after March.
  • isRateOverLastYear: a boolean variable to detect dates with opening rates better than last year. As we see later we will focus on the top ones to identify the peaks.
  • localityPosition: an integer value that determines the position of the cumulative sum of Opening Rate to determine the localities whose businesses are normalizing faster. The lower the best, we’ll see the best 3 localities per country.

Visualizations

Let’s go for the good! After doing all the data preparation process we have the dataset ready, to begin with, the visualizations and thus identify the reasons for the peaks in the opening rates.

Focusing on the top three states that have this new normal, we observe that several of them are reaching last year’s levels, others emerging from two quarantines, and finally, others starting a forced lockdown again.

Image by Carlos León
Image by Carlos León

Conclusions

  1. Doing a visual exploratory analysis of the data can give you a great idea of what is happening in your business. Track the trends and understand the reason for the peaks.
  2. Prepare your dataset with the necessary dimensions (some of them hidden in your data) is the key.
  3. Data manipulation was done in Python and the plots were made in R and Adobe Illustrator. To get deep into the code, go to my git hub repository here.
  4. Here is a useful reference for how to use the spaghetti chart in R.

Related Articles