liveBook · Manning

Set difference

As explained in Build Python Web Apps with Streamlit

A delta is the difference between a metric's value in a main period and its value in a comparison period.

A delta shows how a metric changed between a main period and a comparison period. Calculate both periods separately, then display the difference beside the main value. section 7.4.2

Comparing monthly sales

If August sales are $5M and July sales are $4M, the difference is $1M. Expressed relative to July, the delta is 20%, so the dashboard can show “$5M, up 20% from the previous period.” section 7.4.2

Implement the comparison in two steps:

  • Filter the comparison dataframe using the same category, gender, and other filters as the main dataframe, but use the comparison dates. section 7.4.2

How Build Python Web Apps with Streamlit covers it

How deep it goes
Explains separate filtering, percentage calculation, formatting, and display, while stopping short of broader statistical interpretation.
Examples
Uses August and July sales, filtered dataframes, percentage formatting, and a metric bar as concrete examples.
What it assumes
Assumes metric values, date ranges, filters, and basic dataframe handling; teaches the delta workflow through dashboard code.
What you can do after
Build it from scratch by calculating and formatting percentage deltas for Streamlit metric bars.
How it connects
Connects comparison periods, percentage change, pandas dataframes, and Streamlit metric displays.

Also explained in

Compare how 2 books explain set difference →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.