如何向 Streamlit data_editor 中的列添加动态标签?

问题描述 投票:0回答:1

我创建了一个 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

python python-3.x tags streamlit
1个回答
0
投票

不幸的是,目前

st.data_editor
无法实现这一点。 这里是跟踪此功能请求的 GitHub 问题。

© www.soinside.com 2019 - 2024. All rights reserved.