liveBook · Manning

Missing value

As explained in Data Storytelling with Altair and AI

A missing value is an absent or unrecorded value for an observation and variable in a dataset.

A missing value is an absent observation in a dataset. It matters because calculations can quietly become misleading when the data for a period or category is incomplete. Before combining values by year, check whether every country and year needed by the comparison is represented. section 2.2.1

Incomplete boundary years

Tourist-arrival series contain gaps for some countries and years. The 1990 starting year is unavailable for some countries, while 2019 ends in October rather than covering a full year. Summing or comparing these incomplete years with complete annual totals could distort the apparent trend. section 2.2.1 section 2.3.1

There is no single automatic response to missing values: choose a treatment that fits the analysis goal and the pattern in the data. For a progressively growing time series, excluding incomplete boundary years can provide a comparable range. Here, restricting the analysis to 1994–2018 preserves years with usable data before annual totals are calculated. section 2.3.1

A practical workflow for this time-series case is:

  • Load the data into a pandas DataFrame and parse the Date field as dates. section 2.2.1
  • Extract the year from Date, then retain only rows from 1994 through 2018. section 2.3.1
  • Group retained rows by Year and Country, then sum tourist arrivals and reset the index. section 2.3.1
  • Plot the resulting yearly values as Altair line charts, using only the comparable range. section 2.3.1
Table 2.1 Arrivals at tourist arrivals establishments since 1994
Date
IT
FR
DE
PT
ES
UK
1990-01-01
2,543,920
3,185,877
325,138
1723,786
1,776,000
1990-02-01
2,871,632
3,588,879
381,539
1,885,718
2,250,000
1990-03-01
3,774,702
4,272,437
493,957
2,337,847
2,662,000
…
…
…
…
…
…
…
2019-08-01
11,649,500
13,692,822
14,570,339
2,531,809
12,893,366
8,889,049
2019-09-01
9,888,817
11,684,845
14,373,815
2,263,748
5,858,984
2019-10-01
7,692,388
10,401,793
13,780,441
1,995,942
7,455,781

Inspect the country-by-date table to see why completeness must be checked before yearly aggregation or comparison. section 2.2.1

Filtering incomplete years with pandas

Create a Year column from Date, then filter out years before 1994 and after 2018. This approach removes incomplete endpoints rather than treating partial annual data as directly comparable totals. section 2.3.1

Listing 2.8 Removing missing years from the dataset
df.loc[:, 'Year'] = df['Date'].dt.year   #1
df = df[(df['Year'] >= 1994) & (df['Year'] <= 2018)]   #2

The filtering listing shows the date-to-year conversion and the inclusive 1994–2018 range restriction. section 2.3.1

Filtering is a decision about what claim a chart can support. A chart of annual growth should compare like with like: complete annual periods. Once the comparable range is selected, yearly sums and percentage increases can support a clearer trend-focused visualization. section 2.3.1

How Data Storytelling with Altair and AI covers it

How deep it goes
Explains a context-dependent filtering strategy, year extraction, grouped sums, and charting, without covering imputation or broader missing-data methods.
Examples
Uses tourist arrivals by country, missing 1990 data, partial 2019 data, and a 1994–2018 pandas filtering workflow.
What you can do after
Apply it via pandas and Altair to restrict a time series to comparable years before aggregating and charting it.
How it connects
Connects missing values with pandas DataFrames, date parsing, time series, grouping, aggregation, and Altair line charts.

Also explained in

Compare how 35 books explain missing value →

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.