liveBook · Manning

St.cache_data

As explained in The Well-Grounded Data Analyst

A Streamlit decorator that caches data-returning function results to avoid repeated computation or loading.

st.cache_data caches results from data-loading helper functions so datasets are not reloaded whenever a user performs an action, such as changing a dropdown. section 11.2.2

Apply it by wrapping a helper function with the decorator, then call that function when preparing data for the Streamlit app.

Caching house-price data

@st.cache_data def get_price_data(): return helpers.load_price_data() wales = get_price_data()

How The Well-Grounded Data Analyst covers it

How deep it goes
Explains decorator placement and shows cached helper calls, but does not detail cache invalidation or storage internals.
Examples
Demonstrates cached price data, county lists, and county ridgeplot data in a Wales house-price explorer.
What it assumes
Assumes basic Python functions and Streamlit app construction while demonstrating the decorator pattern directly.
What you can do after
Operate/configure Streamlit data loading by decorating helper functions whose results should persist across user actions.
How it connects
Connects data caching with Streamlit apps, helper functions, dropdown interactions, and derived datasets.

Also explained in

Compare how 2 books explain st.cache_data →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Well-Grounded Data Analyst. The section links point to the parts of the book it draws on.