我创建了一个 Streamlit data_editor
edited_df
,如下所示。我想向 data_editor 添加一个动态标签列(st_keywords),以便用户添加/删除标签。这可能吗?
import streamlit as st
import pandas as pd
from streamlit_tags import st_tags
df = 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},
]
)
edited_df = st.data_editor(df)
#How do I add this as a new column to edited_df?
st_keywords = st_tags(
label='# Enter Keywords:',
text='Press enter to add more',
value=['Zero', 'One', 'Two'],
suggestions=['five', 'six', 'seven',
'eight', 'nine', 'three',
'eleven', 'ten', 'four'],
maxtags = 4,
key='1')
预期输出将是 data_editor,并添加新列
st_tags
: