streamlit-component-gallery / pages /data.dataframe2.py
whitphx's picture
whitphx HF staff
Copy https://github.com/whitphx/stlite/tree/main/packages/sharing-editor/public/samples/011_component_gallery
dd0ef30
raw history blame
No virus
621 Bytes
import pandas as pd
import streamlit as st
# Cache the dataframe so it's only loaded once
@st.experimental_memo
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)