Loading CSV Data
The standard approach is to read your CSV with Pandas inside a cached function. The@st.cache_data decorator tells Streamlit to run the function only once, then store the result in memory. On subsequent reruns (triggered by widget interactions), Streamlit returns the cached DataFrame instantly instead of re-reading the file.
Handling Uploaded Files
When you want users to bring their own data, combinest.file_uploader with pd.read_csv:
Displaying DataFrames
Filtering DataFrames with Widgets
Combining Pandas filters with Streamlit widgets is the heart of interactive data apps. User selections from widgets become filter conditions on your DataFrame:NumPy Calculations
NumPy integrates naturally into Streamlit. You can display NumPy outputs withst.write() or use them to feed charts:
Rendering Matplotlib Charts
Streamlit renders Matplotlib figures withst.pyplot(fig). Always create the figure explicitly using the object-oriented interface (fig, ax = plt.subplots()) to avoid state leakage between reruns.
Always pass the
fig object explicitly to st.pyplot(fig). Calling st.pyplot() without an argument (using the global Matplotlib state) is deprecated and can produce unexpected charts as your app grows.