Multiselect default value error

Hi! I am new to using streamlit and I love it so far.
But I am having issues with the multiselect. This is my code:

defaultcols = [“Hotel_Adress”, “Review_Date”, “Average_Score”, “Hotel_Name”, “Reviewer Nationality”]

cols = st.multiselect(“Columns”, df.columns.tolist(), default= defaultcols)
st.dataframe(df[cols].head(10))

The error I get is:
StreamlitAPIException: Every Multiselect default value must exist in options

I am using the newest version of streamlit-0.60.0 on my mac.
Is there anyone who can help me in the right direction?

Looks like some of the cols in defaultcols aren’t present in your dataframe - I’d double check that with something like

assert set(defaultcols).issubset(df.columns)

The first list of columns you pass to St is the list of possible choices, and the second is the list of choices selected by default.

2 Likes

Thank you for the quick reply! It indeed was the case that I missed some things. Thank you for time!