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!