streamlit-component-gallery / pages /data.data_editor1.py
whitphx's picture
whitphx HF staff
Copy sample files from streamlit/docs/python/api-examples-source/* (4e54057)
9c1ffe9
raw
history blame contribute delete
No virus
588 Bytes
import pandas as pd
import streamlit as st
@st.cache_data
def load_data():
return pd.DataFrame(
[
{"command": "st.selectbox", "rating": 4, "is_widget": True},
{"command": "st.balloons", "rating": 5, "is_widget": False},
{"command": "st.time_input", "rating": 3, "is_widget": True},
]
)
df = load_data()
edited_df = st.data_editor(df, num_rows="dynamic", use_container_width=True)
favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
st.markdown(f"Your favorite command is **{favorite_command}** 🎈")