I wanted to use streamlit selectbox so users can select from a column in the pandas data frame. I have executed the code properly but it takes too long for streamlit to load the option because the total number of entries in the list is huge. Is there any solution to reduce the time or to have a search box kind of feature so that all the options are not loaded into the dropdown box ? Thanks in advance.
Steps to reproduce
Code snippet:
song_list = df['name'].unique()
user_name = st.selectbox('Choose your favourite song here',song_list)
Expected behavior:
It takes too long for the code to process and the drop down menu to appear.
Actual behavior:
I would like to reduce the time it takes for the drop down menu to appear or the drop down menu does not appear and we just get a search bar and it takes less time.
I’m not sure how to solve your problem using a selectbox, but instead you could use streamlit aggrid to display the options and return the song the user clicks on
Depending on your use case, you could consider doing a textbox and just using whatever the user types to filter down the list that is then displayed (probably checking to see if they’ve entered at least 2-3 characters before doing anything). If you wanted to do this “live”, you could use the streamlit-keyup component for this GitHub - blackary/streamlit-keyup: Streamlit text input that returns value on keyup
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.