How can I update st.data_editor to remove a choice from a categorical dropdown? In the below example, I’m attempting to display a dataframe that allows the user to select the person responsible for bringing each item. A person can only bring one item, so after the person is selected, I would like to remove that person from the dropdown so they can’t be selected again.
I can retrieve the edited data from edited_df, but I’m not seeing how I use that to remove those options from the categorical dropdown.
Thanks!
data = {'person_responsible': ['', '', '', '', ''],
'item': ['bread', 'cheese', 'fruit', 'cookies', 'drinks'],
}
df = pd.DataFrame(data)
people = ['Jim', 'Bob', 'Sue', 'Greg', 'Jan', 'Peter', 'Marsha', 'Alice']
df.person_responsible = df.person_responsible.astype('category')
df.person_responsible = df.person_responsible.cat.add_categories(people)
edited_df = st.data_editor(df)
st.write(edited_df)