dear boss
Please review my code; it generates an error when attempting to add the DataFrame column names as a list to the st.multiselect list.
For the multiselect items, I would appreciate any ideas and the correct code to resolve this issue.
Thank you for your assistance.
see my code
import pandas as pd
import streamlit as st
technologies = {
‘Courses’:[“Spark”,“PySpark”,“Python”,“Pandas”,“Python”,“Spark”,“Pandas”],
‘Fee’ :[20000,25000,22000,30000,25000,20000,30000],
‘Duration’:[‘30days’,‘40days’,‘35days’,‘50days’,‘40days’,‘30days’,‘50days’],
‘Discount’:[1000,2300,1200,2000,2300,1000,2000]
}
df = pd.DataFrame(technologies)
st.write(df)
colname = list(df)
st.write(colname)
options = st.multiselect(
“What are your favorite colors?”,
[[colname]],
default=[colname[0]],
)
see error
streamlit.errors.StreamlitAPIException: The default value ‘Courses’ is not part of the options. Please make sure that every default values also exists in the options.
Traceback:
File "C:\pytest\coltodf.py", line 14, in <module>
options = st.multiselect(
^^^^^^^^^^^^^^^File "C:\Users\Ali\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\streamlit\runtime\metrics_util.py", line 410, in wrapped_func
result = non_optional_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Users\Ali\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\streamlit\elements\widgets\multiselect.py", line 230, in multiselect
return self._multiselect(
^^^^^^^^^^^^^^^^^^