chapter two

2 Running your first data story in Altair and GitHub Copilot

 

This chapter covers

  • Introduction to Altair
  • Prerequisites
  • Use Case: Describing the Scenario
  • First Approach: Using Altair
  • Second Approach: Using Copilot

In this chapter, we will look at the basic concepts behind Altair, and then we will implement a practical use case, which will allow us to transform a raw dataset into a story. We will progressively apply the Data, Information, Knowledge, Wisdom (DIKW) pyramid principles in Altair and see the results achieved step by step. In the second part of the chapter, we will use Copilot to automate some steps of the story creation process. We will focus only on Copilot as a Generative-AI tool to keep the chapter simple and the flow understandable. In the next chapters, we will introduce ChatGPT and DALL-E to the DIKW pyramid.

2.1 Introduction to Altair

The Vega-Altair library (Altair, for short) is a declarative Python library for statistical visualization based on the Vega and Vega-Lite visualization grammars. Vega is a visualization grammar for creating expressive and interactive data visualizations. Vega-Lite is a high-level declarative language built on top of Vega, designed to simplify the creation of common data visualizations with concise and intuitive syntax. We will discuss Vega and Vega-lite in the next chapter.

2.1.1 Chart

2.1.2 Mark

2.1.3 Encodings

2.2 Use Case: Describing the Scenario

2.2.1 The Dataset

2.2.2 Data Exploration

2.3 First Approach: Altair

2.3.1 From Data to Information

2.3.2 From Information to Knowledge

2.3.3 From Knowledge to Wisdom

2.3.4 Comparing Altair and Matplotlib

2.4 Second Approach: Copilot

2.4.1 Loading and Cleaning the Dataset

2.4.2 Calculating the Percentage Increase

2.4.3 Plotting the Basic Chart in Altair

2.4.4 Enriching the Chart

2.5 Summary

2.6 References