An Interactive Dashboard for Airport Traffic
By: Lewi Uberg
Tags: Data Visualization, Pandas, Python, Dash, Plotly

An Interactive Dashboard for Airport Traffic

Photo by Tomas Williams on Unsplash

Live demo of the dashboard Active-Airport or see the project at GitHub.

Abstract

Norway is geographically a large country compared to other European nations, especially when comparing landmass versus its inhabitants. Norway has industrial epicenters spread across the country. Many Norwegian companies often open new smaller offices to get the right people if they are unwilling to move or if there are enough people in that location to make economic sense. Moreover, a company’s location may be geographically divided when one company acquires another. Such factors have resulted in a lot of domestic airline travel. The publicly available dashboard described in this article aims to provide a visually pleasing and intuitive user experience with the tools needed to see the number of passengers for a given airport or comparing different airports depending on the type of traffic and date.

Introduction

This article describes the data gathering and its preparation for usage in the design and implementation of an exploratory dashboard aimed at giving a clear picture of the domestic airport passenger flow in Norway for a given location or date.

Functions

Helper functions are defined and stored in functions.py and imported as needed to the jupyter notebook used to prepare the data. The reason for doing it like this is to make the Jupyter notebook easier to work with. It has been noticed that some of the extensions in nbextensions tend to have a lag if the notebook has many cells or if it is very long. My preference is to have everything in one notebook from the first to the last step.

Dataset Gathering & Preparation

The data used for exploration in the dashboard is gathered from the Norwegian governmental statistics agency SSB, which has the most recent and detailed data and a publicly available API. However, for simplicity, a table is created from a form-selection and downloaded as a CSV file[1]. The categories chosen to include were passenger amount, month, year, airport name, and traffic type. However, only domestic flights and passengers on board at departure and arrival are included as per the task description. The Norwegian alphabet has three extra letters Æ, Ø, and Å, which all are included in the airport names. However, SSB’s CSV generator does not support these characters, and they are substituted with a ”?” symbol. Since there is no way to make a script to change these without context, each airport is manually renamed if needed.

Import data

The CSV file is structured with columns for each feature ”airport”, ”type of traffic”, ”domestic/international flights”, ”passenger group”, and each date is denoted as ”Passengers yyyyMmm”. For further processing, the CSV file is imported to a Pandas DataFrame.

Preprocessing

The function for renaming either column names or index names is applied. The function is used to split ”yyyy” from ”mm”, remove the ”M” and convert the column to the ”datetime” data type.

The dataset is checked for missing values that could cause problems later, but none are found.

Instances of missing data: 0

Columns with missing data: 0

Column names with missing data: None

Wide data

The dataset in its current state is called ”wide data”, and it is not well suited for making graphs. But some of the following operations are easier in the wide form, so it will not be changed yet.

For geographical representation, location data is required. The function defined above that finds the geographical point for every airport based on its name is applied, theirby adding new columns with location data to the DataFrame.

Missing Data

After applying the geographical location function, we find some missing values. Apparently, It could not identify all the airports in Norway.

Instances of missing data: 70

Columns with missing data: 5

Column names with missing data: location, point, latitude, longitude, and altitude

The missing_location() function defined above is used to locate where the missing values are located, in order to decide what to do next.

After some snooping around, the airport names that didn’t yield a location are found.

While there are only two airports, which makes the manual steps quick and easy, it is also an excellent opportunity to learn how to get an address from geographical data. While working in Jupyter, the kernel sometimes has to be restarted, and some of these steps are time-consuming, so the result is exported to a CSV file. Now the processed data can be imported rather than being reprocessed.

Instances of missing data: 0

Columns with missing data: 0

Column names with missing data: None

Long data

Before making the dashboard the dataset is transformed into ”long data”, where the date columns are melted into the dataset, so every row has a date. Some unnecessary columns generated by different processes are dropped, and time and day are subtracted from the dates since they are all the same due to not being available from the source. The data is now ready for use, and a process for quickly updating it is established.