liveBook · Manning

Quantitative data

As explained in Data Storytelling with Altair and AI

Quantitative data contains numerical values that represent amounts or measurements.

Quantitative data contains numerical values that represent amounts or measurements. In visualization, it maps naturally to positions, sizes, colors, and other visual properties through a quantitative encoding. section 2.1.3 section 3.2.1

Altair marks a quantitative field with Q, either in a shorthand such as `Age:Q` or through a channel's type property. This distinguishes numerical values from nominal categories, ordinal order, and temporal dates. section 2.1.3 section 3.2.1

Use quantitative data to:

  • Place measurements on chart axes, such as age, product sales, or tourist arrivals. section 2.1.3 section 3.2.1
  • Aggregate numerical records, such as summing tourist arrivals by year and country. section 2.3.1
  • Calculate derived measures, such as percentage increases from a selected baseline. section 2.3.1

Encoding age in a bar chart

A DataFrame containing names, ages, and cities can encode `Age:Q` on the x-axis and `Name:N` on the y-axis. The resulting chart represents each person's numerical age against a nominal name. section 2.1.3

Listing 2.3 Encodings in Altair
import pandas as pd
import altair as alt

data = {'Name': ['Alice', 'Bob', 'Charlie'],
        'Age': [25, 30, 35],
        'City': ['New York', 'Paris', 'London']
}                                   #1

df = pd.DataFrame(data)      #2

# Create the chart
chart = alt.Chart(df).mark_bar(
).encode(
    x = 'Age:Q',     
    y = 'Name:N' 
)

chart.save('bar-chart.html')

Inspect a runnable Altair example that creates a DataFrame and encodes its numerical Age column with `Age:Q`. section 2.1.3

How Data Storytelling with Altair and AI covers it

How deep it goes
Defines quantitative types, shows Q syntax, and applies aggregation and derived percentages, but does not develop mathematical theory.
Examples
Uses ages, product sales, tourist arrivals, yearly sums, and percentage increases as concrete numerical examples.
What it assumes
Assumes DataFrame columns and basic chart construction while distinguishing numerical fields from categorical and temporal fields.
What you can do after
Apply it via Altair to encode numerical fields, aggregate measurements, calculate changes, and communicate trends visually.
How it connects
Connects quantitative data with encodings, data visualization, nominal data, ordinal data, temporal data, missing values, and time series.

Also explained in

Compare how 7 books explain quantitative data →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Storytelling with Altair and AI. The section links point to the parts of the book it draws on.