Spaces:
Runtime error
Runtime error
| import pandas as pd | |
| import streamlit as st | |
| # Cache the dataframe so it's only loaded once | |
| def load_data(): | |
| return pd.DataFrame( | |
| { | |
| "first column": [1, 2, 3, 4], | |
| "second column": [10, 20, 30, 40], | |
| } | |
| ) | |
| # Boolean to resize the dataframe, stored as a session state variable | |
| st.checkbox("Use container width", value=False, key="use_container_width") | |
| df = load_data() | |
| # Display the dataframe and allow the user to stretch the dataframe | |
| # across the full width of the container | |
| st.dataframe(df, use_container_width=st.session_state.use_container_width) | |