liveBook · Manning

Conditional formatting

As explained in Build Python Web Apps with Streamlit

A conditional formatting rule is a display rule that applies presentation changes when data satisfies a specified condition.

Conditional formatting changes how data appears when it meets a rule. In a pandas DataFrame, the style property can apply presentation changes without changing the underlying values. section 7.5.3 section 7.8

Highlighting a total row

A drilldown table adds a row labeled “Total.” A styling function examines each row and returns a background-color rule for every cell when the first cell contains “Total”; other rows receive no style.

Formatting can be composed with value formatting: first convert metric values according to their configured types, then apply the conditional row style before displaying the table.

How Build Python Web Apps with Streamlit covers it

How deep it goes
Explains row-wise style application, nested functions, conditions, and style lists, but does not develop broader rule systems.
Examples
Uses a drilldown table whose Total row receives a gray background while metric values receive type-based formatting.
What it assumes
Assumes familiarity with pandas DataFrames and basic Python functions while demonstrating nested functions and list comprehensions in context.
What you can do after
Build it from scratch by defining a row condition, returning per-cell style values, and applying the function through DataFrame.style.apply.
How it connects
Connects pandas DataFrames with DataFrame styling, Python nested functions, list comprehensions, and Streamlit dashboard display.

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.